#include #include #define MAX(a,b) ((a)>(b)?(a):(b)) typedef struct farey{ int a,b,c,d; } farey; void run(void){ int x,y; scanf("%d%d",&x,&y); int *cnt=(int *)calloc(y+1,sizeof(int)); int k; for(k=1;k*k<=y;k++) cnt[k*k]+=4; for(k=1;2*k*k<=y;k++) cnt[2*k*k]+=4; farey stack[32]; int top=0; stack[top++]=(farey){0,1,1,1}; while(top>0){ farey f=stack[--top]; int p=f.a+f.c; int q=f.b+f.d; if(p*p+q*q>y) continue; for(k=1;k*k*(p*p+q*q)<=y;k++){ cnt[k*k*(p*p+q*q)]+=8; } if(f.b<=f.d){ stack[top++]=(farey){f.a,f.b,p,q}; stack[top++]=(farey){p,q,f.c,f.d}; } else { stack[top++]=(farey){p,q,f.c,f.d}; stack[top++]=(farey){f.a,f.b,p,q}; } } int max=cnt[x]; for(k=x+1;k<=y;k++) max=MAX(max,cnt[k]); printf("%d\n",max); } int main(void){ run(); return 0; }