HDU-1850 Being a Good Boy in Spring Festival---尼姆博奕的运用

题目链接:

http://acm.hdu.edu.cn/showproblem.php?pid=1850

题目大意:

中文题:

思路:

传送门:尼姆博奕

 1 #include<iostream>
 2 #include<string>
 3 #include<vector>
 4 #include<cstdio>
 5 #include<cstring>
 6 #include<algorithm>
 7 #include<set>
 8 #include<map>
 9 #include<stack>
10 #include<queue>
11 #include<vector>
12 #define FOR(i, a, b) for(int i = a; i < b; i++)
13 #define MEM(a, b) memset(a, b ,sizeof(a));
14 using namespace std;
15 const int INF = 1e9 + 7;
16 const int maxn = 1e3 + 10;
17 int n, T, m;
18 int a[maxn];
19 int main()
20 {
21     while(cin >> n && n)
22     {
23         int x;
24         int sum = 0;
25         for(int i = 0; i < n; i++)
26         {
27             cin >> a[i];
28             sum ^= a[i];
29         }
30         int ans = 0;
31         for(int i = 0; i < n; i++)
32         {
33             if(a[i] > (sum ^ a[i]))//只要某一堆能够大于其他所有堆的异或值,那么这一堆的数目就能变成其他所有堆的异或值
34                 ans++;
35         }
36         cout<<ans<<endl;
37     }
38     return 0;
39 }
原文地址:https://www.cnblogs.com/fzl194/p/8762515.html