Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3969 Accepted Submission(s): 1998
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<stdlib.h> #include<queue> #include<stack> #include<algorithm> #include<ctype.h> #define LL __int64 using namespace std; const int MAXN=200+5; const int INF=0x3f3f3f3f; const double EPS=1e-9; int dir4[][2]={{0,1},{1,0},{0,-1},{-1,0}}; int dir8[][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}}; int dir_8[][2]={{-2,1},{-1,2},{1,2},{2,1},{2,-1},{1,-2},{-1,-2},{-2,-1}}; int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) { if(b<a) swap(a,b); double k=(sqrt(5)-1)/2; int j=(int)a*k; if(a==(int)j*(1+k)) { if(b==a+j) printf("0\n"); else printf("1\n"); } else { if(b==a+j+1) printf("0\n"); else printf("1\n"); } } return 0; }