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(10^6) = 112168.
Find F(10^12).

彼得在有从0到 N连续编号的N+1扇门的走廊里移动,。所有的门最初都是关闭的。彼得从0号门前开始, 并重复执行以下步骤:

•首先, 他走到了离他的位置一个正平方数的门前。

•然后 他走到了离他的新位置另一 更大的平方数的门前。

•他切换他面临的门 ( 如果门关着就打开它, 如果门开着就关闭它)。

•最终回到了0号门。

我们把这些步骤的任何顺序称为动作。彼得从来不执行两次完全相同的动作, 并确保执行所有可能的不带他经过最后一扇门的动作 。

设 F (N) 是在彼得执行了所有可能的动作之后打开的门的数量。已知F (5) = 1, F (100) = 27, F (1000) = 233 和 F (10 ^ 6) = 112168。
求 F (10 ^ 12)。