这是一个威佐夫博弈问题
分析可以发现规律bk = ak + k,其中bk为第k个失败数较大的一个,ak为较小的一个,ak会前面k-1行中没有出现的。
显然有ak > ak-1。判断ak与黄金分割有关,即ak = (1+sqrt(5))/2*k。
#include<iostream>
#include<math.h>
using namespace std;
int main(){
double x = (1.0 + sqrt(5.0))/2.0;
int ak;
int bk;
while(cin>>ak>>bk){
if(ak > bk){//交换ak,bk
ak ^= bk;
bk ^= ak;
ak ^= bk;
}
int k = bk - ak;
if(ak == (int)(k*x))
cout<<0<<endl;
else
cout<<1<<endl;
}
//system("pause");
return 0;
}