Page 2 of 4

Again WA

Posted: Wed Jul 02, 2003 7:58 pm
by Faizur
Hello shamim many many thanks for your reply. I have changed my code:

Code: Select all

#include<stdio.h>
#include<math.h>
#define pi 3.14159
double p;
double fn(double x)
{
	return 4.0*x*cos(x)*cos(x)+pi*(1.00-p)-2.0*x-sin(2.0*x);
}
int main()
{
	double x1,x2,x3,y1,y2,y3,r,R;
	int N;

		scanf("%d",&N);
		while(N--)
		{
			scanf("%lf%lf",&r,&p);
			x1=pi/2;
			x3=0;
			while(fabs(x3-x1)>0.00000000000001)
			{
				x2=(x1+x3)/2.0;
				y2=fn(x2);
				if(y2<0.0000000000000000001)
					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;
}
Still i am getting WA.So i am realy ....
Whether my formula is wrong or something else .Pls help

Posted: Tue Jul 15, 2003 5:12 am
by the LA-Z-BOy
dear Faizur, i haven't checked your code, i just ran it on some inputs and i am giving the i/o s that your prog didn't agree with mine.

Code: Select all

R = 1000, P = 0.02, Rope = 204.49
R = 1000, P = 0.06, Rope = 360.52
R = 1000, P = 0.07, Rope = 390.78
R = 1000, P = 0.08, Rope = 419.16
R = 1000, P = 0.23, Rope = 739.66
R = 1000, P = 0.28, Rope = 825.56
R = 1000, P = 0.30, Rope = 858.40
...where your prog gives something different with +-0.01 or so.
ps. my method is something like bsearch but my equation is independent of PI. i just needed PI(=3.14159) to calculate the `target' area, and i used epsilon 1e-5 for this area (just because i have to keep only two decimal places after the area. both codes with double and long double got accepted.
thanks

Posted: Tue Jul 22, 2003 1:10 pm
by Noim
THanks shamim,

i haved missed that it was a multiple input case program. after seeing your caution i manage to get accept. THanks any way.

Posted: Sat Jul 26, 2003 10:32 am
by Dominik Michniewski
Could anyone tell me , why this program gives me WA ?
I've got right answers for every case which I find in board but OJ says WA.
Could anyone send me some more IO, on which my program fails ??
Computations are given from math books and seems to be allright :(

Best regards
DM

Code: Select all

cutted ...

Posted: Mon Jul 28, 2003 2:13 pm
by the LA-Z-BOy
Hello Dominik
i have Managed to figure out few mistakes in your code, i've sent the modified one via private msg.
thanks
Istiaque Ahmed

Posted: Mon Jul 28, 2003 3:16 pm
by Dominik Michniewski
Thanks La-z-boy for help ...
Strange are two things:
1. on windows, on my computer, all works fine - I don't have UNIX to test :( so it's impossible to find such errors by me :(
2. it's second code, in which I must calculate values with more precision, that I think taht I should ... :( I think, that 1e-5 should be enough, but I see that 100 more is enough ...

Thanks again and again
DM

Posted: Tue Jul 29, 2003 9:36 am
by Faizur
But whats the problem with my code.. :x This problem is making me really crazy....pls check my code..........................

Posted: Fri Aug 08, 2003 12:03 am
by ivec
I have the same output as IIUC GOLD, but still WA.

I believe I am handling the multiple input correctly (I have a bunch of assertions to validate input and check there is no trailing data).

It feels like this is one of these numeric error / rounding problems. I used some classig geometry and trigonometry do define the inverse function (ratio eaten from rope ratio), then do a simple bissective search (and I tried various accuracy thresholds).

The calculation function I use looks like: [c]
double eatenRatio(double ropeRatio)
{
double sqRope = ropeRatio*ropeRatio;
double alpha = 2*acos(1-0.5*sqRope);
double beta = 2*acos( 0.5*ropeRatio );
return 0.5*( (alpha-sin(alpha)) + sqRope*(beta-sin(beta)) ) / 3.14159; /*26535;*/
}
[/c]

Does someone who got AC use a different computation approach ?

hints welcome...

Output of P must be to two decimal places

Posted: Wed Dec 10, 2003 6:46 am
by Chameleon
I kept getting WA for this problem. I eventually guessed that the output of P must be to two decimal places, even though this is not written anywhere in the problem statement. Very annoying.

358 : Confused !

Posted: Sat Dec 27, 2003 2:18 pm
by Sajid
I thought that the following eqn is enough for this problem... but it isnt.

Code: Select all

Area(Rope) = Area(R) * p
PI * Rope^2 = PI * R^2 * p
Rope = R * sqrt(p)
But I dont understand why...

What's wrong with this?

No its not!

Posted: Sat Dec 27, 2003 3:40 pm
by sohel
I wonder how you came up with this formula. If it were that simple, the AC percentage would have been much higher.

From what I can remember, I derived two/three equations and solved it using bisection method.

Posted: Sat Dec 27, 2003 3:44 pm
by shamim
Well, i guess you now know it isn't the right formula. If you stil think so, please justify yourself.

As for the actual solution, you need derive an equation which needs to be solved using Bisection method.

Posted: Sat Dec 27, 2003 4:18 pm
by Sajid
Well, Yes, I knew that this eqn is wrong...
But I wanted to know that what's wrong?

I am not confused to get WA...

Posted: Sat Feb 07, 2004 12:38 pm
by sjn
I got WA several times and don't know why

i got the following result from my program
could anything check it for me?

thx in advanced!

Code: Select all

Input:
51
100 0.00
100 0.01
100 0.02
100 0.03
100 0.04
100 0.05
100 0.06
100 0.07
100 0.08
100 0.09
100 0.10
100 0.11
100 0.12
100 0.13
100 0.14
100 0.15
100 0.16
100 0.17
100 0.18
100 0.19
100 0.20
100 0.21
100 0.22
100 0.23
100 0.24
100 0.25
100 0.26
100 0.27
100 0.28
100 0.29
100 0.30
100 0.31
100 0.32
100 0.33
100 0.34
100 0.35
100 0.36
100 0.37
100 0.38
100 0.39
100 0.40
100 0.41
100 0.42
100 0.43
100 0.44
100 0.45
100 0.46
100 0.47
100 0.48
100 0.49
100 0.50
[/b]

Code: Select all

Output:
R = 100, P = 0.00, Rope = 0.00
R = 100, P = 0.01, Rope = 14.36
R = 100, P = 0.02, Rope = 20.45
R = 100, P = 0.03, Rope = 25.18
R = 100, P = 0.04, Rope = 29.21
R = 100, P = 0.05, Rope = 32.79
R = 100, P = 0.06, Rope = 36.05
R = 100, P = 0.07, Rope = 39.08
R = 100, P = 0.08, Rope = 41.92
R = 100, P = 0.09, Rope = 44.60
R = 100, P = 0.10, Rope = 47.16
R = 100, P = 0.11, Rope = 49.60
R = 100, P = 0.12, Rope = 51.96
R = 100, P = 0.13, Rope = 54.23
R = 100, P = 0.14, Rope = 56.43
R = 100, P = 0.15, Rope = 58.57
R = 100, P = 0.16, Rope = 60.64
R = 100, P = 0.17, Rope = 62.67
R = 100, P = 0.18, Rope = 64.65
R = 100, P = 0.19, Rope = 66.59
R = 100, P = 0.20, Rope = 68.48
R = 100, P = 0.21, Rope = 70.34
R = 100, P = 0.22, Rope = 72.17
R = 100, P = 0.23, Rope = 73.97
R = 100, P = 0.24, Rope = 75.73
R = 100, P = 0.25, Rope = 77.48
R = 100, P = 0.26, Rope = 79.19
R = 100, P = 0.27, Rope = 80.88
R = 100, P = 0.28, Rope = 82.56
R = 100, P = 0.29, Rope = 84.21
R = 100, P = 0.30, Rope = 85.84
R = 100, P = 0.31, Rope = 87.46
R = 100, P = 0.32, Rope = 89.05
R = 100, P = 0.33, Rope = 90.64
R = 100, P = 0.34, Rope = 92.20
R = 100, P = 0.35, Rope = 93.76
R = 100, P = 0.36, Rope = 95.30
R = 100, P = 0.37, Rope = 96.83
R = 100, P = 0.38, Rope = 98.34
R = 100, P = 0.39, Rope = 99.85
R = 100, P = 0.40, Rope = 101.35
R = 100, P = 0.41, Rope = 102.83
R = 100, P = 0.42, Rope = 104.31
R = 100, P = 0.43, Rope = 105.78
R = 100, P = 0.44, Rope = 107.24
R = 100, P = 0.45, Rope = 108.69
R = 100, P = 0.46, Rope = 110.14
R = 100, P = 0.47, Rope = 111.58
R = 100, P = 0.48, Rope = 113.02
R = 100, P = 0.49, Rope = 114.45
R = 100, P = 0.50, Rope = 115.87
[/b]

Posted: Sun Feb 08, 2004 2:57 pm
by sjn
At last i got AC :wink:
when i chose the epsilon with 1e-5 i passed it