#1163: Game & #183; Nim game,

Source: Internet
Author: User

#1163: Game-Nim game,

Question from hihocoder ': http://hihocoder.com/problemset/problem/1163? Sid = 1, 423214

Time Limit: milliseconds ms single-point time limit: 256 Ms memory limit: MB
Description

Today, we want to meet new friends Alice and Bob.
Alice and Bob are always conducting a variety of competitions. Today they are playing a stone-taking game.
In this game, Alice and Bob put N piles of different stones, numbered 1. N. The I heap contains A [I] stones.
For each action, Alice and Bob can choose to take any number of stones from the pile of stones. Take at least one stone and at most all the stones left in the pile.
Alice and Bob take turns to win the person who took the last stone.
Assume that Alice takes action in every round of the game. Please judge who will win the game if both parties are smart enough under the given circumstances?

Prompt: Nim ?!

Input

Row 1st: 1 integer N. Indicates the number of stones. 1 ≤ N ≤100
Row 2nd: N integers. the I-th integer indicates the number of I-th stones A [I], 1 ≤ A [I] ≤ 10000

Output

Row 3: 1 string. If Alice can win, output "Alice"; otherwise, output "Bob"

Sample Input
33 2 1
Sample output
Bob
#include<iostream>using namespace std;int main(){    int n;    cin>>n;    unsigned int res=0,temp;    for(int i=0;i<n;i++)    {        cin>>temp;        res=res^temp;    }    if(res==0)    cout<<"Bob\n";    else    cout<<"Alice\n";}


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.