题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1527
威佐夫博弈:
设k为任意正整数,有以下两个函数:
1、m(k) = k * (1 + sqrt(5)) / 2;
2、n(k) = m(k) + k;
点(m(k), n(k))和点(n(k), m(k))都是P点(必败点),其余都是N点(必胜点)。
详见:http://blog.csdn.net/qust1508060414/article/details/52194676
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
int a, b;
while (cin>>a>>b)
{
if (a > b)
swap(a, b);
int k = b - a;
int mk = (int)k*(sqrt(5)+1)/2;
if (mk == a)
cout<<0<<endl;
else
cout<<1<<endl;
}
return 0;
}
。