Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 5611 Accepted Submission(s): 2137
6 12
3
<span style="font-size:14px;">#include<stdio.h> #include<math.h> int main() { int a,b; while(~scanf("%d%d",&a,&b)) { int lefta,leftb,righta,rightb,len1,len2,sum; len1=ceil(sqrt(a));len2=ceil(sqrt(b)); lefta=(a-(len1-1)*(len1-1)-1)/2+1; leftb=(b-(len2-1)*(len2-1)-1)/2+1; righta=(len1*len1-a)/2+1; rightb=(len2*len2-b)/2+1; sum=fabs(len1-len2)+fabs(lefta-leftb)+fabs(righta-rightb); printf("%d\n",sum); } return 0; } </span>
原文地址:http://blog.csdn.net/ice_alone/article/details/38388397