天天看点

poj1067威佐夫博弈

#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
using namespace std;
#define INF 1000000000
#define maxn
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define mset(x) memset(x,0,sizeof(x))
typedef __int64 ll;

ll a, b;
int main(){
//	freopen("a.txt","r",stdin);
//	freopen(".out","w",stdout);
	while(cin>>a>>b){
		if(a>b)	swap(a,b);
		ll k=b-a;
		double tmp=(sqrt(5.0)+1)/2.0;
		if( a==(ll)(k*tmp) ){
			puts("0");
		}
		else{
			puts("1");
		}
	}
	return 0;
}

/*
DESCRIPTION:
威佐夫博奕,
1 2
3 5
4 7
6 10
8 13
这些组先手必输
发现规律:第k组有 ak=k*(1+√5)/2, bk=ak+k 这些组先手必输,称为奇异局势
*/