http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1995
#include<iostream> using namespace std; int cal(int n) { int ans=0; while(n>0) { ans+=n/2; n/=2; } return ans; } int main() { int a, b; while(scanf("%d %d",&a,&b)!=EOF) { if(cal(a)-cal(a-b) > cal(b)) cout<<0<<endl; else cout<<1<<endl; } }