[Sicily online1087. a funny game

Source: Internet
Author: User
Constraints

Time Limit: 1 secs, memory limit: 32 MB

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 twoAdjacentCoins, leaving all other coins untouched.
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 areNotAdjacent! (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

Question Analysis:

I have always hoped to rely on Dynamic Planning, and the results won't be relied on for half a day.

Answers from online experts:

No matter how the first candidate is selected, the candidates are selected in symmetric positions, so that the remaining number is an even number. Then, no matter how the other candidate is selected, the candidates sit in the same operation in symmetric positions. The latter always wins.

For example, if there are even numbers, select one first, and then select two candidates at Symmetric positions.

I knew that I had to try a few more groups of data. I guess I can see it too.

Http://blog.csdn.net/titikdhu/article/details/5746349

#include<iostream>#include<stdio.h>#include<cmath>#include<iomanip>#include<list>#include <map>#include <vector>#include <string>#include <algorithm>#include <sstream>#include <stack>#include<queue>#include<string.h>using namespace std;int main(){int n;while(cin>>n&&n!=0){if(n==1||n==2)cout<<"Alice"<<endl;else cout<<"Bob"<<endl;}}

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.