HDU1849 Rabbit and Grass(NIM整理)
这类题就是有N堆东西,每次可以取任意堆的任意个
最后取完的获胜
就是把N堆读进来全部异或,不等0就赢了
/* *********************************************** Author :devil Created Time :2016/5/29 11:19:41 ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <assert.h> #include <map> #include <string> #include <cmath> #include <stdlib.h> using namespace std; int main() { //freopen("in.txt","r",stdin); int n; while(~scanf("%d",&n)&&n) { int x,ans=0; while(n--) { scanf("%d",&x); ans^=x; } if(ans) printf("Rabbit Win!\n"); else printf("Grass Win!\n"); } return 0; }