博弈 SG  由于每个a太大,没有办法递推,但是可以找规律

a为偶数  SG(a)=a/2

a为奇数  SG(a)=SG(a/2)

代码:

#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>

#define ll long long
#define lint long long
using namespace std;

const int N=4000005;
ll F(ll a)
{
    if(a==1)
    return 0;
    if((a&1)==0)
    return (a>>1);
    return F(a>>1);
}
int main()
{
    //freopen("data.in","r",stdin);
    int T;
    cin>>T;
    while(T--)
    {
        int n;
        cin>>n;
        ll nim=0;
        for(int i=1;i<=n;++i)
        {
            ll a;
            cin>>a;
            nim=(nim^F(a));
        }
        if(nim==0)
        cout<<"NO"<<endl;
        else
        cout<<"YES"<<endl;
    }
    return 0;
}

 

posted on 2013-07-09 10:20  夜->  阅读(235)  评论(0编辑  收藏  举报