Topic:
1, Game 1:
There are two piles of coins, the number is variable (greater than 0), two people play the game, each time you can take any number of coins from any heap (greater than 0), who took the last coin is the winner.
2, Game 2:
A box, inside a certain number (greater than 0) of chocolate and a pepper, two people to play, each time you can take out 1 or 2 or 3 chocolate, pepper can only last take, who finally took the chili pepper will have to eat her, also lose.
Ideas:
Give the answer first:
Game 1:
If the number of coins is equal, let the other party take first, and then take the number of the pile of coins, so that the number of coins equal, in turn.
If the number of coins is not equal, then take the number of coins first, so that the number of coins is equal, and then let the other side to take, in turn.
Game 2:
If the number of chocolates is a multiple of 4, then let the other party take first, and then take it by themselves, the number is (4-the number of each other), in turn.
If the number of chocolates is not a multiple of 4, then let yourself take, take the quantity (the amount of chocolate%4), and then let the other side to take, and then take the number of their own, take the amount of (4-the number of the other), in turn.
Strategy Induction:
The two games have one thing in common: to find a point of balance.
If the initial state is balanced, then the other person comes first, letting him break the balance, and then to maintain the balance himself.
If the initial state is not balanced, then start by yourself, maintain the balance, then let the other person break, and then to maintain the balance.
Game 1 Balance: Two stacks of coins equal;
Game 2 Balance point: The number of chocolates is a multiple of 4;
Find the balance, you can determine the priority of the game and every step of the strategy, the winner's strategy is to continue to maintain the balance.
(algorithm) Game win strategy