atcoder#ARC091D. [ARC091F] Strange Nim
[ARC091F] Strange Nim
Score : points
Problem Statement
Takahashi and Aoki are playing a stone-taking game. Initially, there are piles of stones, and the -th pile contains stones and has an associated integer .
Starting from Takahashi, Takahashi and Aoki take alternate turns to perform the following operation:
- Choose a pile. If the -th pile is selected and there are stones left in the pile, remove some number of stones between and (inclusive) from the pile.
The player who first becomes unable to perform the operation loses the game. Assuming that both players play optimally, determine the winner of the game. Here, represents the largest integer not greater than .
Constraints
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi will win, print Takahashi
; if Aoki will win, print Aoki
.
2
5 2
3 3
Aoki
Initially, from the first pile at most stones can be removed at a time, and from the second pile at most stone can be removed at a time.
- If Takahashi first takes two stones from the first pile, from the first pile at most stone can now be removed at a time, and from the second pile at most stone can be removed at a time.
- Then, if Aoki takes one stone from the second pile, from the first pile at most stone can be removed at a time, and from the second pile no more stones can be removed (since ).
- Then, if Takahashi takes one stone from the first pile, from the first pile at most stone can now be removed at a time, and from the second pile no more stones can be removed.
- Then, if Aoki takes one stone from the first pile, from the first pile at most stones can now be removed at a time, and from the second pile no more stones can be removed.
No more operation can be performed, thus Aoki wins. If Takahashi plays differently, Aoki can also win by play accordingly.
3
3 2
4 3
5 1
Takahashi
3
28 3
16 4
19 2
Aoki
4
3141 59
26535 897
93 23
8462 64
Takahashi