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;}
- Sicily 1920. Divide The Stones
- Sicily 1920 Divide The Stones
- 1920. Divide The Stones
- Quantity Of The Stones
- Stones on the Table
- Stones on the Table
- A. Stones on the Table
- hdu 4573 Throw the Stones
- poj 3400 Dropping the stones
- coderforces Stones on the Table
- Chef -- Divide the Tangerine
- Divide the Sequence
- Divide the Sequence
- uva10256 The Great Divide
- Divide the Sequence
- Stones
- Stones
- Stones
- iOS网络协议----HTTP/TCP/IP浅析
- Notification学习(1)
- 树形结构的处理——组合模式(一):设计杀毒软件的框架结构
- Hibernate使用自定义脚本替换注解或者xml文件中的自动生成表结构
- dede安装出现dir 织梦cms重新安装出现dir怎么办
- Sicily 1920. Divide The Stones
- JavaScript基础——高级技巧
- 在Python3.4下,用cx_freeze打包PyQt4程序
- 嵌入式开发环境准备
- 视音频数据处理入门:H.264视频码流解析
- 《老码农教你学英语》
- JS日期加减,日期运算
- android Launcher文件夾功能分析
- python的threading和multiprocessing模块初探