A and B are playing a game. At the beginning there are n coins. Given two more numbers x and y. In each move a player can pick x or y or 1 coins. A always starts the game. The player who picks the last coin wins the game or the person who is not able to pick any coin loses the game. For a given value of n, find whether A will win the game or not if both are playing optimally.
can anyone tell me why in case of n=10 , x= 5 , y = 4 A is losing ?
in one of following case A is winning
n = 10 => A picks 4 n = 6
n = 6 => B picks 5 n = 1
n = 1 => A picks 1 n= 0 A is winner
but correct answer is B is winner can any one tell me why ?
what is wrong in exhaustive dfs type approach and returning true if in anycase A would win ? and if there are any related problems to practice here ?