题目链接:http://poj.org/problem?id=2234
Nim博弈游戏。代码如下:
1 #include <iostream> 2 #include <math.h> 3 #include <stdio.h> 4 #include <cstdio> 5 #include <algorithm> 6 #include <string.h> 7 #include <string> 8 #include <sstream> 9 #include <cstring> 10 #include <queue> 11 #include <vector> 12 #include <functional> 13 #include <cmath> 14 #include <set> 15 #define SCF(a) scanf("%d", &a) 16 #define IN(a) cin>>a 17 #define FOR(i, a, b) for(int i=a;i<b;i++) 18 #define Infinity 999999999 19 #define NInfinity -999999999 20 #define PI 3.14159265358979323846 21 #define MAXN 1000000005 22 #define RATIO (sqrt(5.0)+1.0)/2.0 23 typedef long long Int; 24 using namespace std; 25 26 int main() 27 { 28 int N; 29 int nums[25]; 30 while (SCF(N) != EOF) 31 { 32 FOR(i, 0, N) 33 SCF(nums[i]); 34 int ans = nums[0]; 35 FOR(i, 1, N) 36 { 37 ans = ans^nums[i]; 38 } 39 if (ans == 0) 40 printf("No\n"); 41 else 42 printf("Yes\n"); 43 } 44 return 0; 45 }