zoukankan      html  css  js  c++  java
  • HDU Be the Winner [Anti-SG]

    传送门

    n堆,每次拿走至少一个,剩下的可以分成两堆。最后拿的人输


    打表观察发现和Nim游戏一样...裸Anti-SG

    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    using namespace std;
    typedef long long ll;
    const int N=1e6;
    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;
    int main(){
        //freopen("in","r",stdin);
        while(scanf("%d",&n)!=EOF){
            int sg=0,flag=0;
            for(int i=1;i<=n;i++) a=read(),sg^=a,flag|=a>1;
            if( (sg==0 && !flag) || (sg!=0 && flag) ) puts("Yes");
            else puts("No");
        }
    }
  • 相关阅读:
    第二周作业
    十二周
    十一周
    第十周
    第九周
    第八周
    第七周
    第六周
    实验报告三
    第四周课程总结&试验报告(二)
  • 原文地址:https://www.cnblogs.com/candy99/p/6551219.html
Copyright © 2011-2022 走看看