[poj2234]Matces Game_博弈论

Matches Game poj-2234

题目大意:n堆石子的Nim游戏,anti-SG。

注释:$1\le n\le 20$。


想法:用Colon定理即可。具体见:小约翰的游戏

最后,附上丑陋的代码... ...

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		bool flag=false; int ans=0;
		for(int i=1;i<=n;i++)
		{
			int x; scanf("%d",&x);
			ans^=x; if(x>1) flag=true;
		}
		printf("%s\n",((ans&&flag)||(!ans&&!flag))?"Yes":"No");
	}
}

小结:Nim游戏强强强。

全部评论

相关推荐

不愿透露姓名的神秘牛友
12-17 17:40
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务