POJ 2484 A Funny Game (IQ Game), poj2484

Source: Internet
Author: User

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;}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.