POJ 2484 A Funny Game (IQ Game), poj2484
Time Limit:1000 MS |
|
Memory Limit:65536 K |
Total Submissions:6397 |
|
Accepted:3978 |
Description
Alice and Bob decide to play a funny game. at the beginning of the game they pick n (1 <= n <= 106) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins, leaving all other coins untouched. at least one coin must be removed. players alternate moves with Alice starting. the player that removes the last coin wins. (The last player to move wins. if you can't move, you lose .)
Figure 1
Note: For n> 3, we use c1, c2,..., cn to denote the coins clockwise and if Alice remove c2, then c1 and c3 are NOT adjacent! (Because there is an empty place between c1 and c3 .)
Suppose that both Alice and Bob do their best in the game.
You are to write a program to determine who will finally win the game.
Input
There are several test cases. each test case has only one line, which contains a positive integer n (1 <=n <= 106 ). there are no blank lines between cases. A line with a single 0 terminates the input.
Output
For each test case, if Alice win the game, output "Alice", otherwise output "Bob ".
Sample Input
1230
Sample Output
AliceAliceBob
Source
POJ Contest, Author: Mathematica @ ZSU
233 times easier than I thought, times faster than I thought.
It seems that SG cannot be obtained. It must be a mysterious question.
It turns out that I am still a fool.
Conclusion: If n = 2 or n = 1, the first hand wins. Otherwise, the second hand wins.
Proof:
When $ n $ is an even number, no matter how the first hand moves, the latter will always follow the center symmetric imitation of the first hand
When $ n $ is an odd number, no matter how the first hand goes, the latter will always perform the opposite operation to construct the first case.
#include<cstdio>int main(){ int T_T; while( scanf("%d",&T_T) && T_T ) T_T>2?printf("Bob\n"):printf("Alice\n"); return 0;}