A Game of Pencils
Problem Description
Two players are playing a game. They have A bundles of pencils of size B each.
They also have a number C that they chose randomly. They move in turns and the person who's unable to make a move loses.
For each move a person chooses a bundle and divides it into some number (more than one) of equal parts/bundles, the size of each one is expressed by an integer and is no less than C.
Each resulting part is also a bundle which can be divided in future by any player.
Find the winner of the game.
Problem Constraints
1 <= A <= 10^5
1 <= B, C <= 10^9
Input Format
First argument is the integer A.
Second argument is the integer B.
Third argument is the integer C.
Output Format
Return 1 of the First player wins, 0 if Second player wins.
Example Input
Input 1:
A = 4
B = 8
C = 6
Input 2:
A = 1
B = 9
C = 2
Example Output
Output 1:
0
Output 2:
1
Example Explanation
Explanation 1:
Player 1 cannot divide any of the bundle, so that the divided bundles have size not less than 6. Hence he loses.
Explanation 2:
They have only 1 bundle to start with. Player 1 has only one valid move where he divides this bundle into 3 bundles of size 3.
After this Player 2 cannot divide bundles of size 3 further. Hence Player 2 loses.