Time Limit: 2 secs, Memory Limit: 32 MB
Description
Alice and Bob like game theory very much. They want to practise in a new game. There are N piles of stones. Each pile of stones may have different number of stones. They take turns to play, and Alice always play at the first turn.
At each turn, one pile of stones must be divided into two piles of stones, and there is at least one stone in either pile. Who can not divide the stones will lose.
If they both play optimally, who will win in the game?
Input
In the first line, there is one integer T(1<=T<=60).
Then T test cases follow. In the first line of each test cases, there is one integer N(1<=N<=50000), the number of piles in the game. In the second line of each test case, there are N integers, a1, a2 … an, the number of stones in each piles.(1<=ai<=10^9)
Output
For each test case, out put one line with “Alice” or “Bob”(without quotes), the winner of the game.
Sample Input
2
3
1 2 3
4
6 7 8 9
Sample Output
Alice
Bob
^_^ JUST DO IT!
#include <iostream>
using namespace std;
int main()
{
int T, N, Temp;
cin >> T;
while (T--)
{
int sky = 0; // sky 表示总的操作数
cin >> N;
while (N--)
{
cin >> Temp;
sky += (--Temp); // 值为Temp的数要完全分解需要(Temp-1)次操作
}
if (sky & 1) // 判断奇偶数的快捷运算,如果所需操作总数为奇数次则Alice胜出否则Bob胜
cout << "Alice" << endl;
else
cout << "Bob" << endl;
}
return 0;
}