出现奇异局面,先取者必败,反之后拿者必败
奇异局面:(0,0) (1,2) (3,5) (4,7) (ak,bk)
ak=bk-k,ak=k*(1+√5)/2;
代码实现(poj 1067):
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
double v=(sqrt(5.0)+1)/2;
int a,b;
while(~scanf("%d %d",&a,&b))
{
int k=a>b?a-b:b-a;
//cout<<k<<endl;
if(a>b) swap(a,b);
if(floor(k*v)==a)
{
//cout<<k<<" "<<v<<endl;
cout<<"0"<<endl;
}
else
{
cout<<"1"<<endl;
}
}
return 0;
}
时间: 2024-10-03 21:41:15