0%

Problem 963


Problem 963


Removing Trits

NOTE: This problem is related to Problem 882. It is recommended to solve that problem before doing this one.

Two players are playing a game. When the game starts, each player holds a paper with two positive integers written on it.
They make moves in turn. At a player’s turn, the player can do one of the following:

  • pick a number on the player’s own paper and change it by removing a $0$ from its ternary expansion (base-$3$ expansion);
  • pick a number on the opponent’s paper and change it by removing a $1$ from its ternary expansion;
  • pick a number on either paper and change it by removing a $2$ from its ternary expansion.

The player that is unable to make a move loses.
Leading zeros are not allowed in any ternary expansion; in particular nobody can make a move on the number $0$.

An initial setting is called fair if whichever player moves first will lose the game if both play optimally.

For example, if initially the integers on the paper of the first player are $1, 5$ and those on the paper of the second player are $2, 4$, then this is a fair initial setting, which we can denote as $(1, 5 \mid 2, 4)$.

Note that the order of the two integers on a paper does not matter, but the order of the two papers matter.
Thus $(5, 1 \mid 4, 2)$ is considered the same as $(1, 5 \mid 2, 4)$, while $(2, 4 \mid 1, 5)$ is a different initial setting.

Let $F(N)$ be the number of fair initial settings where each initial number does not exceed $N$.

For example, $F(5) = 21$.

Find $F(10^5)$.


移除三进制位

:本题与第882题相关;建议在尝试本题之前先解决后者。

两位玩家正在玩一个游戏;游戏开始时,每位玩家手中都拿着一张纸,上面写有两个正整数。
两位玩家轮流行动,轮到某位玩家行动的回合,该玩家可以执行以下操作之一:

  • 选择自己纸上的一个数,并从其三进制表示中移除一个$0$;
  • 选择对手纸上的一个数,并从其三进制表示中移除一个$1$;
  • 选择任意一张纸上的一个数,并从其三进制表示中移除一个$2$。

首先无法行动的玩家落败。
任何三进制表示中都不允许有前导零;特别地,玩家不能对$0$进行操作。

如果某个初始局面满足,在双方都采取最优策略时先手必败,则称其为公平的

例如,如果一位玩家纸上的整数最初是$1, 5$,另一位玩家纸上的整数是$2, 4$,那么这是一个公平的初始局面,我们可以将其表示为$(1, 5 \mid 2, 4)$。

注意,调换一张纸上的两个整数的顺序被视为相同局面,但调换两张纸的顺序被视为不同局面。
因此$(5, 1 \mid 4, 2)$被视为与$(1, 5 \mid 2, 4)$相同,而$(2, 4 \mid 1, 5)$则被视为一个不同的初始局面。

令$F(N)$为所有初始整数都不超过$N$的公平初始局面的数量。

例如,$F(5) = 21$。

求$F(10^5)$。