HDU 1850 Being a Good Boy in Spring Festival

典型的Nim博弈题

View Code
 1 #include<iostream>

 2 #include<cstdio>

 3 #include<cstdlib>

 4 #include<algorithm>

 5 #include<cmath>

 6 #include<queue>

 7 #include<set>

 8 #include<map>

 9 #include<vector>

10 using namespace std;

11 

12 int main(  )

13 {

14     int num[124],n,tt;

15     while( scanf( "%d",&n ) ,n )

16     {

17         int count = 0, t = 0;

18         for(int i = 0 ; i < n ; i++ )

19         {

20              scanf( "%d",&num[i] );

21              t ^= num[i];        

22         }

23         if( t != 0 )

24         for( int i = 0 ; i < n ; i++ )

25         {

26             tt = t;

27             tt ^= num[i];

28             if( tt <= num[i] ) count++;     

29         }

30         printf( "%d\n",count );

31     }

32     //system( "pause" );

33     return 0;

34 }

 

你可能感兴趣的:(spring)