标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6682 Accepted Submission(s): 4039
3 5 7 9 0
1
题意:中文题.....就不解释了....
分析:一道基础的nim博弈题,知道a^b=c,a^c=b,b^c=a;问题就解决了。
#include <iostream> #include <cstdio> #include <cstring> #include <stack> #include <queue> #include <map> #include <set> #include <vector> #include <cmath> #include <algorithm> using namespace std; const double eps = 1e-6; const double pi = acos(-1.0); const int INF = 1e9; const int MOD = 1e9+7; #define ll long long #define CL(a,b) memset(a,b,sizeof(a)) #define lson (i<<1) #define rson ((i<<1)|1) #define N 50010 int gcd(int a,int b){return b?gcd(b,a%b):a;} int n,a[110]; int main() { while(scanf("%d",&n),n) { int sum=0,ans=0; for(int i=0; i<n; i++) { scanf("%d",&a[i]); sum ^= a[i]; } if(sum==0){cout<<0<<endl; continue;} for(int i=0; i<n; i++) { if((sum^a[i]) <= a[i]) ans++; } cout<<ans<<endl; } return 0; }
hdu1850 Being a Good Boy in Spring Festival(nim博弈)
标签:
原文地址:http://blog.csdn.net/d_x_d/article/details/52124566