题目链接:http://poj.org/problem?id=1067
这是一道威佐夫博奕(Wythoff Game),具体分析参考http://www.cnblogs.com/celia01/archive/2011/11/15/2250171.html
我自己的代码如下:
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
/************************************/
void tt(int x, int y)
{
int t, d;
if( x>y )
{
t=x; /*判断是否为奇异局势*/
x=y;
y=t;
}
d=(double)((y-x)*(sqrt(5.0)+1)/2);
if(d==x) printf("0\n");
else printf("1\n");
}
/*************************************/
int main()
{
int a, b;
while(~scanf("%d%d", &a, &b))
{
tt(a, b); /*调用函数*/
}
return 0;
}