hdu 1849 Rabbit and Grass 博弈论

水题,转化Nim

代码如下:

 

 1 #include<iostream>

 2 #include<stdio.h>

 3 #include<algorithm>

 4 #include<iomanip>

 5 #include<cmath>

 6 #include<cstring>

 7 #include<vector>

 8 #define ll __int64

 9 #define pi acos(-1.0)

10 #define MAX 50000

11 using namespace std;

12 int m,t,ans;

13 int main(){

14     while(scanf("%d",&m)&&m){

15         ans=0;

16         while(m--){

17             scanf("%d",&t);

18             ans^=t;

19         }

20         puts(ans==0?"Grass Win!":"Rabbit Win!");

21     }

22     return 0;

23 }
View Code

 

 

 

你可能感兴趣的:(HDU)