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