|
|
back to boardWa#7 Who can help me?Thanks! WA#7 Here is my code: #include<stdio.h> #include<math.h> main() { long ans,x=0,y,i,j,k=0,l,m,n; scanf("%ld %ld",&m,&n); if(m>n){ans=m;m=n;n=ans;} for(i=0;i<=100009;i++) { if((m>i*i)&&(x==0)&&(m<=(i+1)*(i+1)))x=i+1; if((n>i*i)&&(k==0)&&(n<=(i+1)*(i+1)))k=i+1; if((x!=0)&&(k!=0))break; } y=m-(x-1)*(x-1);l=n-(k-1)*(k-1); if(m!=1)if(y%2==0)x=x*2-2;else x=x*2-1; if(l%2==0)k=k*2-2;else k=k*2-1; ans=fabs(k-x); y=(y+1)/2;l=(l+1)/2; if((l>=y)&&(l<=y+k-x))ans+=0;else { m=abs(l-y);n=abs(y+k-x-l); l=m>n?n:m; ans+=2*l; } printf("%ld\n",ans); return 0; } Re: Wa#7 Who can help me?Thanks! Give me your E-mail adress and i send you this test. |
|
|