Playing With Stones UVALive - 5059 Nim SG函数 打表找规律

Code:

#include
#include
using namespace std;
typedef long long ll;
ll SG(ll i){
    return i % 2 ==0 ? i / 2 : SG(i/2);
}
ll arr[100000];
int main(){
    //freopen("input.in","r",stdin);
    int T;
    scanf("%d",&T);
    while(T--){
        int n;
        ll sum=0;
        scanf("%d",&n);
        for(int i=1;i<=n;++i) {
            ll a;
            scanf("%lld",&a);
            sum^=SG(a);
        }
        if(sum==0) printf("NO\n");
        else printf("YES\n");
    }
    return 0;
}

  

你可能感兴趣的:(Playing With Stones UVALive - 5059 Nim SG函数 打表找规律)