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"); } }
Copyright:http://www.cnblogs.com/candy99/