【洛谷2252&HDU1527】取石子游戏(博弈论)

题面

HDU1527 取石子游戏

洛谷2252 取石子游戏

题解

裸的威佐夫博弈

#include<iostream>
#include<cmath>
using namespace std;
const double phi=(sqrt(5)+1)/2;
int a,b;
int main()
{
	ios::sync_with_stdio(false);
	while(cin>>a>>b)
	{
		if(a>b)swap(a,b);
		int A=abs(a-b)*phi;
		if(A==a)cout<<0<<endl;
		else cout<<1<<endl;
	}
	return 0;
}

posted @ 2018-08-15 19:58  小蒟蒻yyb  阅读(431)  评论(0编辑  收藏  举报