Problem Statement
Alice and Bob play a game with a pile of stones.
Initially, there are n stones in the pile.
The players take alternating turns, Alice goes first.
Each turn of the game looks as follows:
- The current player choses a number X between 1 and m, inclusive. X cannot exceed the current number of stones in the pile.
- The current player removes X stones from the pile.
- If the pile is now empty, the current player wins the game.
- The current player counts the remaining stones in the pile, and writes that count in binary. If that number contains an odd number of ones, the current player loses the game.
Definition
- Class:
- ThueMorseGame
- Method:
- get
- Parameters:
- int, int
- Returns:
- String
- Method signature:
- String get(int n, int m)
- (be sure your method is public)
Constraints
- n will be between 1 and 500,000,000, inclusive.
- m will be between 1 and 50, inclusive.
- n will have an even number of ones in binary.
Examples
3
3
Returns: "Alice"
Here Alice can take three stones from the heap and win.3
2
Returns: "Bob"
If Alice can take one or two stones. Either case, remaining number of stones will contain an odd number of ones in binary.387
22
Returns: "Alice"
499999999
50
Returns: "Alice"
499999975
49
Returns: "Bob"