Today, I am engaged in game theory! Start with the most classic game theory!
There are n stones in a pile, and a and B take turns (1 ~ M) a rock. It is required that a should take the first stone and win the light first (that is, the person who takes the last stone wins ), both parties are smart enough (both parties adopt the best decision-making strategy ).
Given n, m asked who can win.
First look at some instances: If m = 2; then n = 1, n = 2, A can directly win. When n = 3, Jia will lose whatever he gets. When n = 4, 5, Jia can take one piece first, and then there are more than 2 stones left. Therefore, Jia still has the opportunity to take it again, and take the remaining light. When n = 6, it is found that a will lose no matter how he gets it.
After some examples, we can draw some conclusions: If n is less than or equal to m, then Jia wins.
If a is an integer multiple of (m + 1) after a request is obtained, a can take control of the entire game and win the game. Next, if B gets k blocks, a will take m + 1-k blocks, and a will ensure that they get m + 1 blocks in each round, so that they can loop in sequence, until the last group of m + 1 stones is left, it is B's turn to take the stones. Because the remaining number of stones is m + 1, B cannot play, then, Jia can play and win the game.
Therefore, if n % (m + 1) is not 0, that is, if A is equal to an integer multiple of m + 1 after a is obtained, a wins. Otherwise, B wins.
This is the basic application of the legendary Bashi game.