码迷,mamicode.com
首页 > 其他好文 > 详细

[poj2234]Matces Game_博弈论

时间:2018-09-09 20:31:59      阅读:132      评论:0      收藏:0      [点我收藏+]

标签:nim游戏   string   size   ring   https   span   print   int   class   

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游戏强强强。

[poj2234]Matces Game_博弈论

标签:nim游戏   string   size   ring   https   span   print   int   class   

原文地址:https://www.cnblogs.com/ShuraK/p/9614871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!