hdu 5011 nim博弈 (2014西安网赛E题)

n堆石子,每次可以选一堆取走至少一个,之后你可以不操作或者把该堆石子分成两堆,每堆至少一个,和还是原来(取完石子后)的石子个数。


Sample Input
1
1
2
1 1
3
1 2 3

Sample Output
Win
Lose
Lose

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <string>
 5 # include <algorithm>
 6 # include <cmath>
 7 # include <queue>
 8 # define LL long long
 9 using namespace std ;
10 
11 
12 int main ()
13 {
14    // freopen("in.txt","r",stdin) ;
15     int n ;
16     while(scanf("%d" , &n) != EOF)
17     {
18         int i , x ;
19         int sum = 0 ;
20         for (i = 1 ; i <= n ; i++)
21         {
22             scanf("%d", &x) ;
23             sum ^= x ;
24         }
25         if (sum)
26            printf("Win
") ;
27         else
28            printf("Lose
") ;
29     }
30 
31     return 0 ;
32 }
View Code
原文地址:https://www.cnblogs.com/mengchunchen/p/4603714.html