26.2k views
5 votes
Maoge and Maoge233 are playing a game.

There are two piles of stones, each time a player can choose one pile of stones, and take away any number of stone(s) from that pile. The person who takes the last stone wins.

Maoge always plays first and we want to know who will be the winner. Assume that both of them take the most optimal strategy.

Input
One line provides two numbers x, y, indicating the number of stones in the two piles, respectively

Output
The winner's name as a string, maoge or maoge233.

Constraint:
x,y<=100000

User Fnery
by
9.1k points

1 Answer

6 votes

Final answer:

In this game, the winner is determined by the condition x mod (y + 1) is not equal to 0 or y mod (x + 1) is not equal to 0. Maoge and Maoge233 play optimally to win.

Step-by-step explanation:

In this game, both players will play optimally to win. We can analyze the game using mathematical induction. Let's assume that if there are x stones in one pile and y stones in the other pile, the current player will win if and only if x mod (y + 1) is not equal to 0 or y mod (x + 1) is not equal to 0. If x mod (y + 1) is equal to 0, it means that the current player will lose no matter how many stones are removed from the piles. The same logic applies if y mod (x + 1) is equal to 0.

For example, if we have 4 stones in one pile and 5 stones in the other pile, Maoge can choose to remove 1 stone from the pile with 5 stones. Now, there are 4 stones in one pile and 4 stones in the other pile. No matter what move Maoge233 makes, Maoge can always copy the move and ensure that y mod (x + 1) is equal to 0 after Maoge's move. Therefore, Maoge will win this game.

User ConfusedKid
by
8.1k points