【洛谷P2252】取石子游戏

题面

题解

威佐夫博弈

代码

#include<cstdio>
#include<algorithm>
#include<cmath>
#define RG register

const double Phi((sqrt(5) + 1.) / 2.);
int a, b;
inline int abs(int a) { return a < 0 ? a : -a; }

int main()
{
	while(~scanf("%d%d", &a, &b))
	{
		if(a > b) std::swap(a, b);
		int c = abs(a - b) * Phi;
		if(c == a) puts("0");
		else puts("1");
	}
	return 0;
}
posted @ 2018-10-19 21:41  xgzc  阅读(488)  评论(0编辑  收藏  举报