Sicily 1920. Divide The Stones

来源:互联网 发布:js清除浏览器history 编辑:程序博客网 时间:2024/06/06 17:16

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;}
0 0
原创粉丝点击