POJ 1704 Georgia and Bob(尼姆博弈)

很简单,这个可以转化成尼姆博弈的模型。

因为两两之间的空格就相当于石子(因为它们相对而言,前一个能移动多少步,后一个也能移动相同的个数,所以相对位置是没有变化的 最后改变的还是它们之间差距的大小)

注意奇数特判就行了。

 /*
 qq:1239198605
 ctgu_yyf
        */

#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,k;
int s[1010];
 
int main()
{
    int T;
    scanf("%d",&T);
    while(T--)
    {
        scanf("%d",&n);
        for(int i=1; i<=n; i++)
            scanf("%d",&s[i]);
        sort(s+1, s+n+1);
        int ans;
        if(n%2 == 0)
        {
            ans = s[2]-s[1]-1;
            for(int i=4; i<=n; i+=2) ans ^= (s[i]-s[i-1]-1);
            if(ans == 0) cout<<"Bob will win"<<endl;
            else cout<<"Georgia will win"<<endl;
        }
        else
        {
            ans = s[1]-1;
            for(int i=3; i<=n; i+=2) ans ^= (s[i]-s[i-1]-1);
            if(ans == 0) cout<<"Bob will win"<<endl;
            else cout<<"Georgia will win"<<endl;
        }
    }
    return 0;
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值