After a long contest, Peanut has decided to reward you for your hard work. In order to do that, he will play a game of NIM with you.
A game of NIM is played in this way:
- The game starts with a pile of N stones.
- The turns alternate between you and Peanut. During each turn, you must pick at least 1 stone and at most M stones from the pile.
- The person who picks the last stone wins.
Your program is to implement the following functions:
- void startGame(int N, int M), which starts the game with N stones.
- int pickStones(int N), which is called during your turn with N stones left. You are supposed to return the number of stones you want to pick.
Your marks will be based on the percentage of games you have won. It is guranteed that there is a way to win the game if you play it optimally.
There is no input for this problem. Refer to the problem statement for more details.
There is no output for this problem. Refer to the problem statement for more details.
1 <= N, M <= 1 000 000