358 - Don't Have A Cow

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

Moderator: Board moderators

..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

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??
ithamar
Learning poster
Posts: 56
Joined: Mon May 13, 2002 11:58 pm
Location: Venezuela

Post by ithamar »

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 :-?
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

hi, I already solved this question, do you need any help?
ithamar
Learning poster
Posts: 56
Joined: Mon May 13, 2002 11:58 pm
Location: Venezuela

Post by ithamar »

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.
..
A great helper
Posts: 454
Joined: Thu Oct 18, 2001 2:00 am
Location: Hong Kong

Post by .. »

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! :D
Saiful Karim
New poster
Posts: 3
Joined: Mon May 06, 2002 7:38 pm

Post by Saiful Karim »

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.
Last edited by Saiful Karim on Mon Jul 08, 2002 12:43 pm, edited 1 time in total.
Saiful Karim
New poster
Posts: 3
Joined: Mon May 06, 2002 7:38 pm

Accepted 358

Post by Saiful Karim »

At last I've got Accepted
Even
Learning poster
Posts: 75
Joined: Thu Nov 22, 2001 2:00 am
Location: Taiwan

Post by Even »

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
MAXX^FACTOR
New poster
Posts: 7
Joined: Mon Sep 16, 2002 7:29 am
Location: EARTH.ASIA.TAIWAN.TAIPEI
Contact:

Post by MAXX^FACTOR »

NEVER GIVE UP ! :lol:
ashutoshkorde
New poster
Posts: 6
Joined: Mon May 05, 2003 1:48 pm

358 - Don't Have A Cow

Post by ashutoshkorde »

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 :o
ashutoshkorde
New poster
Posts: 6
Joined: Mon May 05, 2003 1:48 pm

Re: Accepted 358

Post by ashutoshkorde »

oh illustrous one ...
can u please explain how u did it ?
Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm

help on 358 pls...

Post by Faizur »

Can any one supply me some sample i/o of problem 358 pls......
IIUC GOLD
New poster
Posts: 19
Joined: Tue Jun 11, 2002 4:27 pm
Location: Bangladesh
Contact:

Post by IIUC GOLD »

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
Faizur
New poster
Posts: 39
Joined: Fri Jun 06, 2003 3:04 pm

358wa

Post by Faizur »

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
shamim
A great helper
Posts: 498
Joined: Mon Dec 30, 2002 10:10 am
Location: Bozeman, Montana, USA

Post by shamim »

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

Return to “Volume 3 (300-399)”