PLAYGAME - PLAYGAME
Hemlata and Ragini were playing a game from a number of coins. Hemlata was jealous of Ragini. She wanted to win at all cost. A stack consists of n coins. Any player can take either 1, 2 or 5 (anyone number of coins) coins from stack at a time. Both Hemlata and Ragini play their moves alternatively.
Hemlata always starts first. Both play optimally. Your job is to predict the output beforehand. A player who can't take any coin loses the game. A player can take only one of 1, 2, 5 number of coins at a time in a move.
First line contains number of testcases t. 0 < t <= 10^5
An integer n denoting number of coins. 0 <= n <= 10^18
For each testcase printf "Hemlata" if Hemlata wins, else print "Ragini" if Ragini wins (without quotes) in different lines .
Input: 3 1 2 3
Output: Hemlata Hemlata Ragini
@useandthrowone: Basic game theory knowledge :)
can we solve this using dp? n is too large
Can someone plz mention the topics to be learnt to solve this problem?
aman224: what are the rules? "A player who can't take any coin loses the game". Seems clear to me...
@vengatesh15: O(1) should be O(t).