358  Don't Have A Cow
Moderator: Board moderators
Can anyone give me some sample I/O?
I try to solve it by bisection (because I can't find a formula of the required area)
here is output of my program:
R = 100, P = 0.33, Rope = 90.64
R = 100, P = 0.10, Rope = 47.16
R = 1, P = 0.00, Rope = 0.00
R = 1, P = 0.33, Rope = 0.91
R = 1, P = 0.50, Rope = 1.16
R = 1000, P = 0.00, Rope = 0.00
R = 1000, P = 0.33, Rope = 906.36
R = 1000, P = 0.50, Rope = 1158.73
Is there any trick with this question? Especially any trick on the rounding??
I try to solve it by bisection (because I can't find a formula of the required area)
here is output of my program:
R = 100, P = 0.33, Rope = 90.64
R = 100, P = 0.10, Rope = 47.16
R = 1, P = 0.00, Rope = 0.00
R = 1, P = 0.33, Rope = 0.91
R = 1, P = 0.50, Rope = 1.16
R = 1000, P = 0.00, Rope = 0.00
R = 1000, P = 0.33, Rope = 906.36
R = 1000, P = 0.50, Rope = 1158.73
Is there any trick with this question? Especially any trick on the rounding??
I resove this problem solving this equation:
4x * Cos(x) * Cos(x) + pi * (1 p)  2x  Sin(2*x) = 0.
x is the angle that form the Radio of the circle and the cord that is formed by the cow rope. With x is easy to deduce what is teh value of the Rope length. I solve the above equation using NewtonRamson and my results are the same that your results so i dont see what is wrong. There is another special case besides p = 0. ?. Do u think that could be that NewtonRamson is losing the solution so i beter implement Bisection?
Thanxs for the help.
4x * Cos(x) * Cos(x) + pi * (1 p)  2x  Sin(2*x) = 0.
x is the angle that form the Radio of the circle and the cord that is formed by the cow rope. With x is easy to deduce what is teh value of the Rope length. I solve the above equation using NewtonRamson and my results are the same that your results so i dont see what is wrong. There is another special case besides p = 0. ?. Do u think that could be that NewtonRamson is losing the solution so i beter implement Bisection?
Thanxs for the help.
hm.....I forget how NewtonRamson method is, I use bisection to solve it.
When I use bisection, I have a "target area", and I want to find "rope length" such that f(rope_length) = target area
The trick is:
target area should be calculated by PI = 3.14159
But when I calculate f(x), I need to use PI = acos(0)*2
I don't know if this fits on you, but I know some other people can get accepted by using similar way......
Good luck!
When I use bisection, I have a "target area", and I want to find "rope length" such that f(rope_length) = target area
The trick is:
target area should be calculated by PI = 3.14159
But when I calculate f(x), I need to use PI = acos(0)*2
I don't know if this fits on you, but I know some other people can get accepted by using similar way......
Good luck!

 New poster
 Posts: 3
 Joined: Mon May 06, 2002 7:38 pm
I sent the solution several times but got W.A. I don't know what's the wrong with my solution. I think it's for floating point error!!! Can anyone tell me exactly what is the required O/P for the problem. I'm confused with
the input for P. Is the O/P for P also should be correct to 2 decimal point? Please help me.
the input for P. Is the O/P for P also should be correct to 2 decimal point? Please help me.
Last edited by Saiful Karim on Mon Jul 08, 2002 12:43 pm, edited 1 time in total.

 New poster
 Posts: 3
 Joined: Mon May 06, 2002 7:38 pm
Accepted 358
At last I've got Accepted
ouput P should be correct to 2 decimal point ..that is, if in C, use %.2lfSaiful Karim wrote:I sent the solution several times but got W.A. I don't know what's the wrong with my solution. I think it's for floating point error!!! Can anyone tell me exactly what is the required O/P for the problem. I'm confused with
the input for P. Is the O/P for P also should be correct to 2 decimal point? Please help me.

 New poster
 Posts: 7
 Joined: Mon Sep 16, 2002 7:29 am
 Location: EARTH.ASIA.TAIWAN.TAIPEI
 Contact:

 New poster
 Posts: 6
 Joined: Mon May 05, 2003 1:48 pm
358  Don't Have A Cow
i got the following results from my program are they ok ?
cos i'm getting a W.A. :
R = 100, P = 0.33, Rope = 38.38
R = 100, P = 0.10, Rope = 13.04
R = 100, P = 0.50, Rope = 55.48
i started by calculating the area of the intersecting circles formed by the rope and the pasture and used the bisection method to get the accurate rope length.
i have a pile of papers on which i have derived the formulas
cos i'm getting a W.A. :
R = 100, P = 0.33, Rope = 38.38
R = 100, P = 0.10, Rope = 13.04
R = 100, P = 0.50, Rope = 55.48
i started by calculating the area of the intersecting circles formed by the rope and the pasture and used the bisection method to get the accurate rope length.
i have a pile of papers on which i have derived the formulas

 New poster
 Posts: 6
 Joined: Mon May 05, 2003 1:48 pm
Re: Accepted 358
oh illustrous one ...
can u please explain how u did it ?
can u please explain how u did it ?
help on 358 pls...
Can any one supply me some sample i/o of problem 358 pls......
358wa
Code: Select all
#include<stdio.h>
#include<math.h>
#define pi 3.14159
double p;
double fn(double x)
{
return 4*x*cos(x)*cos(x)+pi*(1p)2*xsin(2*x);
}
int main()
{
double x1,x2,x3,y1,y2,y3,r,R;
while(scanf("%lf%lf",&r,&p)==2)
{
x1=pi/2;
x3=0;
while(fabs(x3x1)>0.00000000000001)
{
x2=(x1x3)/2.0+x3;
y2=fn(x2);
if(y2<0.00000000000001)
x1=x2;
else
x3=x2;
if(fabs(y2)<0.00000000000001)
{x1=x2;break;}
}
R=2*r*cos(x1);
printf("R = %.lf, P = %.2lf, Rope = %.2lf\n",r,p,R);
}
return 0;
}
but alas i am continuously getting WA with the above code .
Can anyone help me with some sample i/o.
Any suggestion will be very much helpful