HDU 2509 Be the Winner

这题Nim博弈;这一就是要考虑全部为1的情况;

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 n ,m,t;

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

16     {

17          t = 0 ;

18          int flag = 0;

19          while( n -- )

20          {

21             scanf( "%d" ,&m );

22             if( m > 1 ) flag = 1;

23             t ^= m;       

24          }

25          if( flag ) 

26          {

27              if( t== 0 ) puts( "No" );

28              else puts( "Yes" );

29          }

30          else 

31          {

32              if( t ) puts( "No" );

33              else

34                  puts( "Yes" );

35          }

36     }

37     //system( "pause" );

38     return 0;

39 }

 

你可能感兴趣的:(inner)