Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 40121

obstacle COURSE not getting answer.

$
0
0
#include<stdio.h>
#include<math.h>


int ischarspace(char x)
{
return x==' '||x=='\n'||x=='\r';
}


inline void fastread(int *x)
{
char c;
int f=0;
*x=0;
c=getchar_unlocked();
while(ischarspace(c))
c=getchar_unlocked();
if(c=='-')
{f=1;
c=getchar_unlocked();
}
while(!ischarspace(c))
{
*x= *x * 10 +(c-48);
c=getchar_unlocked();
}
if(f==1)
*x=-*x;
}



int main()
{
int t,x,y,i,j,n,a,b;
double mid,len,min,ans;
fastread(&t);
while(t--)
{ 
//fastread(&x);
fastread(&x);
fastread(&y);
mid=((double)(y-x)/2);
min=mid;
fastread(&n);
while(n--)
{
fastread(&i);
fastread(&j);
**a=i*i;
b=j*j;
len=sqrt(a+b);   //distance from center
//printf("len = %f\n",len);
len=mid+x-len; // distance from mid of course width
//printf("len = %f\n",len);
if(len<0)
len=-len;
if (len<min)
min=len; //distance of cone which is at min dis 
//printf("min=%f\n",min);
}
ans=mid+min;//diameter of car**
printf("%.3lf\n",ans);
}
return 0;
}

heres my code it is satisfying the sample but online judge is giving wrong answer.. please someone tell whats the mistake in ma code... http://www.codechef.com/problems/COURSE thank you..


Viewing all articles
Browse latest Browse all 40121

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>