301. Nim

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:

If (n1,n2,n3) indicates a Nim position consisting of heaps of size n1, n2, and n3, then there is a simple function, which you may look up or attempt to deduce for yourself, X(n1,n2,n3) that returns:

For example X(1,2,3)=0 because, no matter what the current player does, the opponent can respond with a move that leaves two heaps of equal size, at which point every move by the current player can be mirrored by the opponent until no stones remain; so the current player loses. To illustrate:

For how many positive integers n230 does X(n,2n,3n)=0 ?

301. 尼姆游戏

尼姆取石子游戏 中,玩家需轮流从若干堆石子中,任取一个石堆并从中取走若干枚石子,直至所有石子均被取走。

我们考虑含三堆石子的标准游玩 1 尼姆游戏,其流程为:

(n1,n2,n3) 表示:由分别含有 n1n2n3 枚石子的石堆进行的尼姆游戏,那么,通过查阅资料或自行推导,可以得到:存在一个简单函数 2 X(n1,n2,n3),满足,若两位玩家都绝顶聪明,那么:

例如,X(1,2,3)=0。因为不管先手如何操作,后手都能在一次操作内,留下数量相同的两堆石子。届时,后手一直能模仿先手的操作,直至石子被取完。从而先手必败。举例来说:

对全体 n230 的正整数,有多少个 n 满足 X(n,2n,3n)=0


这个链接 回到源站。

这个链接 回到详细版题目目录。


1 在组合博弈论中,若某组合游戏的获胜规则是走出最后一步的玩家获胜,则称该游戏是标准游玩 (normal-play) 的。
2 若某个函数的值域只由有限个元素组成,则称其为简单函数 (simple function)。