Page 2 of 2

Posted: Fri Jul 05, 2002 8:37 pm
by Picard
are you sure it's not just a compile error because of redefining M_PI (if you include math.h).
this is a good solution and it's very much a spoiler

Posted: Sat Jul 06, 2002 3:00 am
by Joe Smith
Picard wrote:are you sure it's not just a compile error because of redefining M_PI (if you include math.h).
this is a good solution and it's very much a spoiler
This is strange -- I get AC now.

The only thing I remember changing from my most recent WA was I factored out a M_PI... but maybe that did it. Or maybe there was some bad data they changed. (I hate floating point.)

The reason I redefined M_PI (it's only a warning, not a compile error) is because I seem to remember that it wasn't defined in math.h on UVA. I may be wrong on that, but I know hypot isn't defined.

10320 cow trouble

Posted: Tue Sep 10, 2002 7:45 am
by Subeen
my code gets WA. :oops: but i think the problem is simple and easy to solve. i find the area of 3/4 of the circle using the formula pi*R*R, and rest of the area using similar formula.
someone plz find what wrong with my code or the approach is wrong
[c]
#include <stdio.h>
#include <math.h>

#define pi 2*acos(0)

void main()
{
double l, w, R, area, area1, area2, area3;
while(3==scanf("%lf%lf%lf", &l, &w, &R))
{
area2 = area3 = 0;
area1 = 3 * pi * R * R / 4;
if(R >= l)
area2 = pi * (R - l) * (R - l) / 4;
if(R >= w)
area3 = pi * (R - w) * (R - w) / 4;
area = area1 + area2 + area3;
printf("%0.10lf\n", area);
}
}
[/c]
thanx...

Posted: Tue Sep 10, 2002 8:16 am
by Dominik Michniewski
Are yot sure that

Code: Select all

printf("%0.10lf" ....
is similar to

Code: Select all

printf("%.10lf" ....
I think (maybe wrong) that 0.10 prints in some systems something like 0001.00000000 - maybe it's your problem ?

I don't try to solve this question yet and I can't say any word about your algorithm :-(

Best greetings

Moo!

Posted: Tue Sep 10, 2002 1:38 pm
by Yarin
Your solution only works when R<=l+w. This is the easy case, it gets a lot more complicated when R >l+w. Sadly the sample input doesn't have such an input case...

Try the input

7 3 9
9 5 2
18 2 7

The correct answer should be

222.2676802415
9.4247779608
135.0884841044

Posted: Wed Sep 11, 2002 7:31 am
by Subeen
Yarin, I don't understand what do u mean by
Your solution only works when R<=l+w. This is the easy case, it gets a lot more complicated when R >l+w.
after some modification ( area2 = area3 = 0) my program gives the same output as your's.

but still getting WA... :(

Posted: Wed Sep 11, 2002 11:37 am
by Yarin
I'm terribly sorry, I had the parameters the wrong way. The input should be

3 9 7
5 2 9
2 7 18

and the correct answer

128.0199006338
238.3325404965
992.2996351671

which your program does not output.

how is that?

Posted: Wed Mar 05, 2003 12:18 am
by choyon_buet
Thanks to yarin cause i could realize my mistake with my calculation from the sample I/O given by u.And i got this problem accepted at last :D .

but i am so astonished to see that my output doesn't match with yours completely.it differs in the 9th and10th points after the decimal.


suppose for the
input : 5 2 9
my code gives the output: 238.3325404991

so here the last two digits are 91 when ur output is 65.

but both of us got accepted.
CAN U TELL ME HOW IS THAT POSSIBLE? :o

Posted: Mon Mar 10, 2003 9:44 pm
by saiqbal
its possible bcoz its an special judge problem.
an special corrector program is written for this problem to ignore small precision error. :)

10320(Needed formula)

Posted: Tue Dec 18, 2007 10:03 pm
by hridoy
Can anyone plz tell me How can I evaluate the formula when R>(l+w)??

Posted: Wed Dec 19, 2007 8:07 am
by CMG
im not exactly sure myself at the moment, but from observation I found a good approximation for when R>(l+w):

A = (pi*3*R^2)/4 + (pi*(R - l)^2)/4 + (pi*(R - w)^2)/4 - (pi*(R - l - w)^2)/4
= pi*(R^2 - l*w/2)

which gives 238.76104 for the 5 2 9 case above.

If I come up with anything better Ill post it.

Re: 10320 - Cow Trouble! Help Please!!

Posted: Mon Nov 17, 2008 9:21 pm
by Sh0rty
PLs can somebody help me?I have problem like others when R > W+L.I still don`t know resolution for this case.It`s very important for me - Thank you very much.

Re: 10320 - Cow Trouble! Help Please!!

Posted: Sun Apr 17, 2011 10:35 pm
by DD
The most tricky case happens when R > l + w. You need to solve some equations first to get the final answer. 8)
Sh0rty wrote:PLs can somebody help me?I have problem like others when R > W+L.I still don`t know resolution for this case.It`s very important for me - Thank you very much.