Nim on Towers of Hanoi
This problem combines the game of Nim with the Towers of Hanoi. For a brief introduction to the rules of these games, please refer to Problem 301 and Problem 497, respectively.
The unique shortest solution to the Towers of Hanoi problem with disks and pegs requires moves. Number the positions in the solution from index (starting position, all disks on the first peg) to index (final position, all disks on the third peg).
Each of these positions can be considered as the starting configuration for a game of Nim, in which two players take turns to select a peg and remove any positive number of disks from it. The winner is the player who removes the last disk.
We define to be the sum of the indices of those positions for which, when considered as a Nim game, the first player will lose (assuming an optimal strategy from both players).
For , the indices of losing positions in the shortest solution are ,, and . So we have .
You are given that .
Find . Give your answer modulo .
汉诺塔取石子游戏
本题结合了“取石子游戏”和“汉诺塔”这两种游戏,其规则介绍请分别参见第301题和第497题。
对于包含个盘子和根柱子的标准汉诺塔问题,其唯一的最优解法共需步。将该解法中出现的所有状态分别编号,初始状态(所有盘子都在第一根柱子上)编号为,最终状态(所有盘子都在第三根柱子上)编号为。
这种状态中的每一种都可以视为取石子游戏的一个初始布局。由此布局开始,两名玩家轮流选择一根柱子,并从中移走任意数量为正的盘子。移走最后一个盘子的玩家获胜。
考虑所有作为取石子游戏初始布局时先手玩家必败的状态(假设两名玩家均采用最优策略),记为这些状态的编号之和。
对于,所有必败初始状态的编号为、、和,因此。
已知。
求,并将你的答案对取余。
Gitalking ...