My code is working for all the above test cases provided above in the variuos posts. But still I m getting WA. I thought may be uva's compiler uses 2 bytes for int and then changed datatype to even long int and then to even long long. Still getting WA. plz help.

Code: Select all

```
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef pair<long long,long long> pt;
pt findCartesian(long long a)
{
if(a==0)
return make_pair(0,0);
long long n,x,y,b,dx=1,dy=-1;
n=(long long)sqrt(1.0f*a/2);
while(2*n*(n-1)<a)
n++;
b=2*n*(n-1);
x=-1*(n-1);
y=0;
while(b!=a)
{
x=x+dx;
y=y+dy;
if(y==0)
dx=-1*dx;
if(x==0)
dy=-1*dy;
b--;
}
return make_pair(x,y);
}
int main()
{
long long a,b;
float ans;
pt pt1,pt2;
while(1)
{
scanf(" %lld%lld",&a,&b);
if(a==-1&&b==-1)
break;
pt1=findCartesian(a);
pt2=findCartesian(b);
// cout<<"("<<pt1.first<<","<<pt1.second<<") ("<<pt2.first<<","<<pt2.second<<")\n";
ans = sqrt((pt1.first-pt2.first)*(pt1.first-pt2.first)+(pt1.second-pt2.second)*(pt1.second-pt2.second));
printf("%.2f\n",ans);
}
return 0;
}
```