The desired output is obtained on my computer and http://www.compileonline.com
(GNU GCC version 4.8.1) but Codechef gives wrong answer
Please assist me to find the problem
This is the source code
header files used
stdio.h
and
math.h
code:
int main()
{
int t,n,i,j;
float max[500],min,r[2],x[500],s[500],d[500];
scanf("%d",&t);
while(t>0)
{
for(i =0;i<2;++i)
{
scanf("%f",&r[i]);
}
scanf("%d",&n);
for(i=0;i<n;++i)
{s[i]=0;
for(j=0;j<2;++j)
{
scanf("%f",&x[i]);
s[i]+=(x[i]*x[i]);
}
d[i]=sqrt(s[i]);
if(d[i]-r[0]>r[1]-d[i])
{
max[i]=d[i]-r[0];
}
else max[i]=r[1]-d[i];
}
if(max[0]>max[1])
{
min=max[1];
}
else
{
min=max[0];
}
for(i=2;i<n;++i)
{if(max[i]<min)
{
min=max[i];
}
else
{continue;
}
}
printf("%.3lf",min);
t–;}
return 0;
}
The input:
1
5 10
3
6 0
5 7
-2 -7
The Output required:
2.720