Description
Input
Output
Sample Input
2 1 8 4 4 7
Sample Output
0 1 0
该题是一简单的威佐夫博弈,只需要对(a,b)进行判断,判断是否是奇异局势即若a =[k(1+√5)/2],b= a + k (k=0,1,2,...,n 方括号表示取整函数),则为奇异局势输出0,反之则输出1.
代码:
#include<iostream>
#include<cmath>
using namespace std;
int a,b;
int main()
{
double m;
int k;
while (cin>>a>>b)
{
if(a>b) {int temp=a;a=b;b=temp;}
m=(1+sqrt(5.0))/2;
k=b-a;
if(a==int(k*m)) cout<<0<<endl;
else cout<<1<<endl;
}
system("pause");
return 0;
}