UVA 1482 Playing With Stones

Posted 蒟蒻JHY

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA 1482 Playing With Stones相关的知识,希望对你有一定的参考价值。

 

(蓝书里有这个题貌似)

一言不合就打表,可以发现sg数组是个分形的,所以可以推出递推式:

1.x是偶数时,sg(x)=x/2

2.否则,sg(x)=sg(x/2)

 

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
ll sg(ll x){
    return (x&1)?sg(x>>1):x>>1;
}
int T,n;
ll tot,a;
int main(){
    scanf("%d",&T);
    while(T--){
        tot=0;
        scanf("%d",&n);
        while(n--){
            scanf("%lld",&a);
            tot^=sg(a);
        }
        
        if(tot) puts("YES");
        else puts("NO");
    }
    
    return 0;
}

 

以上是关于UVA 1482 Playing With Stones的主要内容,如果未能解决你的问题,请参考以下文章

(转) Playing FPS games with deep reinforcement learning

Playing with OpenCV

Playing with OpenCV

GYM 101061 I. Playing with strings(有待更新)

[DQN] Playing Atari with Deep Reinforcement Learning

[DQN] Playing Atari with Deep Reinforcement Learning