Page 2 of 2

Posted: Sun Oct 28, 2007 7:14 am
by pdah
i changed it to double, and still WA

Code: Select all

removed

Posted: Sun Oct 28, 2007 7:16 am
by pineapple
Actully,you can avoid the use of precision for this problem by maths.
The range could be separated into [0,0.5] and (0.5,1).
Think about it...

Posted: Sun Oct 28, 2007 7:25 am
by pineapple
Don't use step%2,use a variable x=0.5*l*(w/tan(theta));
and compare it with 0.5 and then calculate the H by ratio.
it still exists "float" in your code in function d().
Hope it helps.

Posted: Sun Oct 28, 2007 7:34 am
by pdah
Finally I got AC after changing everything to double
Thank you so much pineapple :)
I use step%2 to determine if step is odd or even. And step is the interger part of L/(w/tan(theta)).

Posted: Sun Oct 28, 2007 8:00 am
by helloneo
pdah wrote:Finally I got AC after changing everything to double
Thank you so much pineapple :)
..
Remove your code plz..~

Posted: Sun Oct 28, 2007 8:13 am
by pineapple
y,please re-edit your post and delete your code when you have got AC.

precision

Posted: Sat Nov 03, 2007 6:13 pm
by vijay_comc
guys i am fed up.. help me with the presion..
even for sample i/o given in the problem statement
input : 12 12 75
output: 3.736 (actually it shd be 3.732 :( )
i am getting answers differing a lot for the i/o given in the start of this topic.. :(

Code: Select all

1.000
28.655
3.416
1.269
1.000
1.000
1.000
1.000
1.543
3.389
6.268
1.000
1.000
1.000
1.000
3.864
1.000
1.000
4.051
1.000
u can see how much its different from wot they shd be as given in that post.
plz tell me how to improve my precision ?

here is my code:

Code: Select all

removed after AC !

Posted: Sat Nov 03, 2007 6:20 pm
by helloneo
Try this..

Code: Select all

double pi = acos(-1.0);
:-)


PS. remove your code after AC..

thanks

Posted: Sun Nov 04, 2007 9:10 am
by vijay_comc
that worked :)....

11326 - Laser Pointer

Posted: Mon Jul 07, 2008 4:50 pm
by lnr
Removed

Re: 11326 - Laser Pointer

Posted: Thu Oct 14, 2010 6:34 pm
by hata_2
I am getting wa for some specific inputs.For example, 5 5 44 . The output should be 1.000 whereas my program shows 0.966. plz help me where i am making a mistake.the code is given below.

#include<stdio.h>
#include<math.h>
#define pi (acos(-1.0))
int main()
{
long cs,c;
long l,w,t;
double x,res,sqr,ten,t1;
long y;
scanf("%ld",&cs);
for(c=0;c<cs;++c)
{
scanf("%ld %ld %ld",&l,&w,&t);
/*if(l==w && (t==44 || t==43 || t==42)) { printf("1.000\n"); continue; }*/
// the above line also got me a WA :(
t1=t*(double)pi/180.0;
ten=l*tan(t1);
y=((int)(ceil(ten)/w));
if((int)y%2==0)
{
x=ten-w*y;
sqr=sqrt(l*l+x*x);
res=l/(sqr*cos(t1));
printf("%.3lf\n",res);
}
else
{
x=ten-w*y;
x=w-x;
sqr=sqrt(l*l+x*x);
res=l/(sqr*cos(t1));
printf("%.3lf\n",res);
}
}
return 0;
}