player can remove 1 or X or Y coins from the tower

A and B are playing a new game today . They form a tower of N coins and make a move in alternate turns . B being the God plays first . In one move player can remove 1 or X or Y coins from the tower . The person to make the last move wins the Game . Can you find out who wins the game ?

actually what I tried with recursion is tsking a bit longe ..... can any one suggest ,e witth dp soln of it


B being the God plays first
I feel A is at a bit of a disadvantage here. Does A get smitten if they win?

In one move player can remove 1 or X or Y coins from the tower
What does this mean? What are X and Y?
Can you find out who wins the game ?


For some input values, either one could win the game. If X=2 and Y=3, for example, either one of them could win the game. Is this the whole question?
The first player always win the game. He left 1 + n * max(1, X, Y) coins at the tower. The second has no chance to win. You need O(1) to solve this.
Oh, do we assume the players are perfectly rational and don't make mistakes? That sure does change things.
Topic archived. No new replies allowed.