每次一人可以从盒子里取出若干条巧克力棒,或是将一根取出的巧克力棒吃掉正整数长度。


 

Nim游戏多了一个决策:拿出一些石堆

显然只要给对方构造异或和为0的子集就行了

暴枚子集...

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=15;
inline int read(){
    char c=getchar();int x=0,f=1;
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}
int n,a[N];
bool solve(){
    int All=1<<n;
    for(int s=1;s<All;s++){
        int sg=0;
        for(int i=0;i<n;i++) if((1<<i)&s) sg^=a[i];
        if(!sg) return true;
    }
    return false;
}
int main(){
    //freopen("in","r",stdin);
    int T=10;
    while(T--){
        n=read();
        for(int i=0;i<n;i++) a[i]=read();
        puts(solve() ? "NO" : "YES");
    }
}

 

相关文章:

  • 2022-12-23
  • 2021-09-23
  • 2021-08-01
  • 2021-12-20
  • 2022-01-22
  • 2022-12-23
  • 2021-05-20
猜你喜欢
  • 2021-10-13
  • 2021-11-14
  • 2021-06-11
  • 2021-09-23
  • 2021-07-23
  • 2021-11-29
  • 2021-12-05
相关资源
相似解决方案