HDU.1850 being a good boy in spring festival (博弈论 尼姆博弈)
HDU.1850 Being a Good Boy in Spring Festival (博弈论 尼姆博弈)
题意分析
简单的nim 博弈
博弈论快速入门
代码总览
#include <bits/stdc++.h>
#define nmax 105
using namespace std;
int a[nmax];
int main()
{
int m;
while(scanf("%d",&m) != EOF && m){
int ans = 0,cnt = 0;
for(int i = 0;i<m;++i){
scanf("%d",&a[i]);
ans ^= a[i];
}
if(ans == 0) printf("0\n");
else{
for(int i = 0 ;i<m;++i){
int k = ans;
k ^=a[i];
if(k < a[i]) cnt++;
}
printf("%d\n",cnt);
}
}
return 0;
}