zoukankan      html  css  js  c++  java
  • BZOJ 1299: [LLH邀请赛]巧克力棒 [组合游戏]

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


    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");
        }
    }
  • 相关阅读:
    用户体验
    jsp ini 配置文件
    Highcharts 图表
    简单游戏服务器
    js 数据操作
    jquery 导航
    as3.0 删除子元件
    java float 保留二位小数
    局域网ip
    SWFUpload
  • 原文地址:https://www.cnblogs.com/candy99/p/6551316.html
Copyright © 2011-2022 走看看