#abc255g. G - Constrained Nim
G - Constrained Nim
Score : points
问题描述
Takahashi 和 Aoki 将使用 堆石子进行一场对决游戏。
最初,对于每个 ,第 堆由 个石子组成。玩家轮流执行以下操作,Takahashi 先手。
- 选择至少剩下一个石子的堆,并移除一个或多个石子。
然而,有 个禁止的操作。
对于每个 ,不允许从恰好由 个石子组成的堆中移除正好 个石子。
第一个无法执行操作的玩家将输掉比赛,从而让另一位玩家获胜。当两位玩家都采用最优策略时,哪位玩家会赢得胜利?
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi and Aoki will play a game against each other using piles of stones.
Initially, for each , the -th pile is composed of stones. The players alternately perform the following action, with Takahashi going first.
- Choose a pile with at least one stone remaining, and remove one or more stones.
However, there are forbidden moves.
For each , it is not allowed to remove exactly stones from a pile composed of exactly stones.
The first player to become unable to perform the action loses, resulting in the other player's victory. Which player will win when both players employ the optimal strategy for the victory?
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi will win when both players employ the optimal strategy for the victory, print Takahashi
; if Aoki will win, print Aoki
.
Sample Input 1
3 4
1 2 4
2 1
3 3
3 1
1 1
Sample Output 1
Takahashi
For each , let be the number of stones remaining in the -th pile. Now, we use the sequence to represent the numbers of stones remaining in the piles.
Before the start of the game, we have . One possible progression of the game is as follows.
- First, Takahashi removes stone from the -rd pile. Now, .
- Next, Aoki removes stones from the -nd pile. Now, .
- Then, Takahashi removes stones from the -rd pile. Now, .
At this point, the -st and -rd piles still have stone each, but it is forbidden ー as the fourth forbidden move ー to remove exactly stone from a pile composed of exactly stone, so Aoki cannot play. Thus, Takahashi wins.
Sample Input 2
1 5
5
5 1
5 2
5 3
5 4
5 5
Sample Output 2
Aoki
update @ 2024/3/10 10:52:26