Problem 611
Hallway of square steps
Peter moves in a hallway with N+1 doors consecutively numbered from 0 through N. All doors are initially closed. Peter starts in front of door 0, and repeatedly performs the following steps:
- First, he walks a positive square number of doors away from his position.
- Then he walks another, larger square number of doors away from his new position.
- He toggles the door he faces (opens it if closed, closes it if open).
- And finally returns to door 0.
We call an action any sequence of those steps. Peter never performs the exact same action twice, and makes sure to perform all possible actions that don’t bring him past the last door.
Let F(N) be the number of doors that are open after Peter has performed all possible actions. You are given that F(5)=1, F(100)=27, F(1000)=233 and F(106)=112168.
Find F(1012).
平方数与走廊
彼得在有N+1扇门的走廊中来回移动,门上依次标有整数0至N。一开始,所有的门都是关着的。彼得从标有0的门开始,重复进行以下步骤:
- 首先,他移动到距离初始位置为一个正平方数的门。
- 然后,他移动到距离新位置为一个更大的平方数的门。
- 他改变现在所面对的门的状态(如果是关着的就打开,如果是开着的就关上)。
- 最后他回到标有0的门。
我们将完整地进行上述步骤称为一次行动。彼得从来不会进行两次完全相同的行动,但同时他会将所有在过程中不会越过最后一扇门的行动都进行一次。
记F(N)为彼得进行完所有可能的行动后开着的门的数量。已知F(5)=1,F(100)=27,F(1000)=233以及F(106)=112168。
求F(1012)。