标签:io for sp c amp size r as poj
//先手能赢 //从n堆石头中的一堆里去掉几颗,有多少堆石头可取 # include <stdio.h> # include <string.h> # include <algorithm> using namespace std; int main() { int n,sum,i,j,a[1010],cot,vis[1010]; while(~scanf("%d",&n),n) { sum=0; for(i=0;i<n;i++) { scanf("%d",&a[i]); } memset(vis,0,sizeof(vis)); cot=0; for(i=0;i<n;i++) { sum=0; vis[i]=1; for(j=0;j<n;j++) { if(!vis[j]) sum^=a[j]; } vis[i]=0; if(a[i]>sum)//要异或到零的状态,因为要取出几个石头,所有a[i]要大于sum,相同的两个数异或为零 cot++; } printf("%d\n",cot); } return 0; }
标签:io for sp c amp size r as poj
原文地址:http://blog.csdn.net/lp_opai/article/details/39348099