Page 1 of 4
Posted: Mon Jan 21, 2002 11:08 am
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??

Posted: Wed May 15, 2002 2:15 pm
I resolve the problem with a diferent method and i get the same answer that you.. So i ant help u. Im in the same situation that u

Posted: Thu May 16, 2002 9:43 am
hi, I already solved this question, do you need any help?

Posted: Thu May 16, 2002 4:38 pm
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 Newton-Ramson 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 Newton-Ramson is losing the solution so i beter implement Bisection?

Thanxs for the help.

Posted: Thu May 16, 2002 6:14 pm
hm.....I forget how Newton-Ramson 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!

Posted: Mon Jul 08, 2002 12:19 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.

Accepted 358

Posted: Tue Jul 09, 2002 9:22 pm
At last I've got Accepted

Posted: Mon Sep 16, 2002 5:42 pm
Saiful 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.
ouput P should be correct to 2 decimal point ..that is, if in C, use %.2lf

Posted: Tue Sep 17, 2002 4:58 am
NEVER GIVE UP !

358 - Don't Have A Cow

Posted: Mon May 05, 2003 1:59 pm
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

Re: Accepted 358

Posted: Fri May 16, 2003 7:48 am
oh illustrous one ...
can u please explain how u did it ?

help on 358 pls...

Posted: Wed Jun 18, 2003 9:25 pm
Can any one supply me some sample i/o of problem 358 pls......

Posted: Sat Jun 21, 2003 4:55 pm
Your Output is not correct. My AC program gives the following output:

R = 100, P = 0.33, Rope = 90.64
R = 100, P = 0.10, Rope = 47.16
R = 100, P = 0.50, Rope = 115.87

358wa

Posted: Mon Jun 30, 2003 8:37 pm

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*(1-p)-2*x-sin(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(x3-x1)>0.00000000000001)
{
x2=(x1-x3)/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;
}``````
This program make me crazy.i applied bisection method.
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

Posted: Wed Jul 02, 2003 12:23 pm
This is Blue ticked problem.
This means that, the first line of input file is an integer indicating the number of test cases to follow.