11326 - Laser Pointer

All about problems in Volume 113. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

pdah
New poster
Posts: 6
Joined: Sat Oct 20, 2007 7:15 pm

Post by pdah »

i changed it to double, and still WA

Code: Select all

removed
Last edited by pdah on Sun Oct 28, 2007 11:44 am, edited 1 time in total.

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post 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...

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post 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.

pdah
New poster
Posts: 6
Joined: Sat Oct 20, 2007 7:15 pm

Post 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)).

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

pdah wrote:Finally I got AC after changing everything to double
Thank you so much pineapple :)
..
Remove your code plz..~

pineapple
Learning poster
Posts: 57
Joined: Fri Nov 03, 2006 3:33 pm

Post by pineapple »

y,please re-edit your post and delete your code when you have got AC.

vijay_comc
New poster
Posts: 3
Joined: Sat Nov 03, 2007 6:01 pm

precision

Post 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 !
Last edited by vijay_comc on Sun Nov 04, 2007 9:09 am, edited 1 time in total.

helloneo
Guru
Posts: 516
Joined: Mon Jul 04, 2005 6:30 am
Location: Seoul, Korea

Post by helloneo »

Try this..

Code: Select all

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


PS. remove your code after AC..

vijay_comc
New poster
Posts: 3
Joined: Sat Nov 03, 2007 6:01 pm

thanks

Post by vijay_comc »

that worked :)....

lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm
Location: Dhaka,Bangladesh

11326 - Laser Pointer

Post by lnr »

Removed

hata_2
New poster
Posts: 2
Joined: Thu Oct 14, 2010 6:23 pm

Re: 11326 - Laser Pointer

Post 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;
}

Post Reply

Return to “Volume 113 (11300-11399)”