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

猜你喜欢

转载自www.cnblogs.com/ShuraK/p/9614871.html