Nim is a game played with heaps of stones, where two players take it in turn to remove any number of stones from any heap until no stones remain.
We'll consider the three-heap normal-play version of Nim, which works as follows:
At the start of the game there are three heaps of stones.
On each player's turn, the player may remove any positive number of stones from any single heap.
The first player unable to move (because no stones remain) loses.
If
zero if, with perfect strategy, the player about to move will eventually lose; or
non-zero if, with perfect strategy, the player about to move will eventually win.
For example
current player moves to
opponent moves to
current player moves to
opponent moves to
For how many positive integers
在 尼姆取石子游戏 中,玩家需轮流从若干堆石子中,任取一个石堆并从中取走若干枚石子,直至所有石子均被取走。
我们考虑含三堆石子的标准游玩 1 尼姆游戏,其流程为:
游戏开始时,有三堆石子。
轮到某位玩家行动时,玩家可以任选一堆石子,并从中取走任意多枚石子(但不能不取)。
首先无法行动的玩家落败。
记
若先手必败,则
若先手必胜,则
例如,
先手从第三堆中取走两枚石子,当前状态:
后手从第二堆中取走两枚石子,当前状态:
先手从第三堆中取走一枚石子,当前状态:
后手从第一堆中取走一枚石子,当前状态:
对全体
点 这个链接 回到源站。
点 这个链接 回到详细版题目目录。