1 #include<iostream> 2 #include<stdio.h> 3 #include<algorithm> 4 #define MAXN 100 5 using namespace std; 6 //把所有堆的石子数目用二进制数表示出来,当全部这些数按位异或结果为0时当前局面为必败局面,否则为必胜局面; 7 int a[MAXN]; 8 void op(int & num); 9 int trans_10_to_2(int num); 10 int main() 11 { 12 //freopen("acm.acm","r",stdin); 13 int num; 14 int i; 15 int tem; 16 int sum; 17 while(cin>>num) 18 { 19 sum = 0; 20 memset(a,0,sizeof(a)); 21 for(i = 0; i < num; ++ i) 22 { 23 cin >> tem; 24 trans_10_to_2(tem); 25 } 26 for_each(a,a+MAXN,op); 27 for(i = 0; i < MAXN; ++ i) 28 { 29 if(a[i] == 1) 30 { 31 cout<<"Yes"<<endl; 32 break; 33 } 34 } 35 if(i == MAXN) 36 cout<<"No"<<endl; 37 } 38 } 39 40 41 int trans_10_to_2(int num) 42 { 43 int mod; 44 int i; 45 i = 0; 46 while(num) 47 { 48 mod = num%2; 49 num /= 2; 50 a[i ++] += mod; 51 } 52 return i; 53 } 54 55 void op(int & num) 56 { 57 if(num % 2 == 0) 58 num = 0; 59 else 60 num = 1; 61 }
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com