您的位置:首页 > 其它

HDU Rabbit and Grass 兔子和草 (Nim博弈)

2015-05-12 11:55 423 查看
思路:简单Nim博弈,只需要将所给的数字全部进行异或,结果为0,则先手必败。否则必胜。

#include <iostream>
using namespace std;
int main()
{
//freopen("input.txt", "r", stdin);
int t, n, m;
while(cin>>t,t)
{
int ans,tmp;
cin>>ans;
for(int i=1; i<t; i++)
{
cin>>tmp;
ans^=tmp;
}
if(ans)
cout<<"Rabbit Win!"<<endl;
else
cout<<"Grass Win!"<<endl;
}
return 0;
}


AC代码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: