poj2234 matches game

题目地址

题解

简单的Nim游戏。
推荐看国家集训队2002年张一飞的论文,他的论文深入浅出地用集合的观点解释了nim游戏和的原理。
之后的很多博弈论的题目都建立在这么一个基本模型的基础上。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <cctype>
#define INF 2000000000
using namespace std;
typedef long long ll;
int (){
int f=1,x=0;char c=getchar();
while(c<'0'||c>'9'){if(c=='-')f=-f;c=getchar();}
while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
return f*x;
}
void init(){

}
void solve(){
int M,a[25],res;
while(~scanf("%d",&M)){
res=0;
for(int i=1;i<=M;i++)a[i]=read(),res^=a[i];
printf("%sn",res?"Yes":"No");

}
}
int main(){
init();
solve();
return 0;
}