POJ 2975 Nim(普通nim)
#include<iostream> #include<cstdio> using namespace std; int main() { int n,k[1005]; int sum,cnt; while(scanf("%d",&n)&&n) { sum=0,cnt=0; for(int i=1;i<=n;i++) { scanf("%d",&k[i]); sum^=k[i]; } if(sum==0) { printf("0\n"); continue; } for(int i=1;i<=n;i++) if(k[i]>=(sum^k[i])) //sum^k[i]要加括号(),不然会WA cnt++; printf("%d\n",cnt); } return 0; }