题目:http://acm.hdu.edu.cn/showproblem.php?pid=1850
题意:对于Nim游戏:有n堆石子,每堆有a[i]个,两人轮流从任意堆中取任意多的石子(一次不能同时从多堆中拿),每次至少
取一个,多者不限,最后取光者胜。先手的人如果想赢,一共有几种选择?
用到了一个很明显的结论:a = a ^ b ^ b;
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
const int N = 155;
int a[N];
int main()
{
int n;
while(cin>>n)
{
if(n==0) break;
int ans = 0;
int sum = 0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum ^= a[i];
}
for(int i=0;i<n;i++)
{
if(a[i] > (sum ^ a[i]))
ans++;
}
cout<<ans<<endl;
}
return 0;
}
题目:http://acm.hdu.edu.cn/showproblem.php?pid=2176