您的位置:首页 > 其它

类似取石子 POJ 1704 Georgia and Bob

2012-08-27 14:16 113 查看
/* http://poj.org/problem?id=1704 当n是奇数时,将第一个数的位置与0绑定,注意输入的数据不一定是按从小到大排序的,所以要进行排序
*/
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int ans[1111];

int main(){
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
int nCase;
cin >>nCase;
while(nCase--){
int n, res = 0;
cin >>n;
ans[0] = 0;
for(int i=1; i<=n; i++)
cin >>ans[i];

sort(ans, ans+n+1);
int i;
if(n%2 == 0)
i = 2;
else
i = 1;

for( ; i<=n; i+=2)
res ^= ans[i]-ans[i-1]-1;

if(res)
cout <<"Georgia will win" <<endl;
else
cout <<"Bob will win" <<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: