[SHOI2002]取石子游戏之三
Wythoff's Game,详解请见浅谈算法——博弈论中的例6
/*program from Wolfycz*/
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define inf 0x7f7f7f7f
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
inline int read(){
int x=0,f=1;char ch=getchar();
for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
for (;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
return x*f;
}
inline void print(int x){
if (x>=10) print(x/10);
putchar(x%10+'0');
}
int main(){
int n,m;
while (~scanf("%d%d",&n,&m)){
if (n<m) swap(n,m);
putchar(trunc(1.0*(n-m)*(1+sqrt(5))/2)==m?'0':'1');
putchar('\n');
}
return 0;
}