Page 1 of 1

### 10297 - Beavergnaw

Posted: Sat Jul 31, 2004 7:57 pm
Maybe I'm not understand the problem thoroughly but I don't know how to caolculate the volumn of 2 cones.Does the cylinder in the center of "D"?

THX...

Posted: Sun Aug 01, 2004 4:31 pm

Try calculus. It's an easy problem.

Good luck.

Posted: Mon Aug 02, 2004 3:15 am
You can also use binary search..

Posted: Mon Aug 02, 2004 7:25 pm
i see,i'll try,thank u guys!!

### 10297 -- need formula

Posted: Thu Aug 12, 2004 3:34 pm
I still cant figur out the formula for this problem.Can anyone give me some hints??THX a lot !!

Posted: Sun Jul 17, 2005 5:07 am
the volumn of 2 cones can be calculated by this formula..

1/3 * pi * r * r * h

r of the circle of its bottom

h is the height of the cone

Posted: Thu Aug 30, 2007 12:35 pm
The formula is:

d=(D^3-6*V/pi)^1/3

(but i'm still getting WA )

### Re: 10297 - Beavergnaw

Posted: Fri May 16, 2008 6:35 am
I don't see any reason of getting W.A.
I used double and solved the problem.

### Re: 10297 - Beavergnaw

Posted: Sat May 17, 2008 10:40 am
For every one getting WA...
Check this point..

Code: Select all

``pi=2*acos(0.0)``
Hope this will solve the problem.

### Re: 10297 - Beavergnaw

Posted: Tue Jun 23, 2009 3:30 am
Hello,
Can anyone give some hint for this problem?
volume=1/3*(D/2)^2*D

### Re: 10297 - Beavergnaw

Posted: Wed Nov 23, 2011 6:39 pm
though the following algorithm is long .but hope it may help u ,as it work fine
1.First find total volume (using the given diameter /height)
2.remaining volume=Total volume - eaten volume
3. then consider the two conic having the base of given D
4.then last remaining volume=(small solid cylinder in the middle-2*small cone)
5. from that find the asked d
best of luck...................

### 10297

Posted: Fri Dec 05, 2014 11:38 am
while submitting my code in ANSI C 4.8.2 language i was getting wrong answer but when i submitted the same code in C++ 4.8.2 language i got accepted..... i am not understanding what differences have been created by changing the submission language.... please help... thanks in advance..here is my code :

Code: Select all

``````#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#define pi acos(-1)
int main()
{
double d,v,voc,vbc,ar,dic;
while(scanf("%lf%lf",&d,&v)==2)
{
if(d==0&&v==0)break;
voc=pi*(d/2.0)*(d/2.0)*d;
vbc=2*(1/3.0)*pi*(d/2.0)*(d/2.0)*(d/2.0);
ar=(voc-vbc)-v;
dic=cbrt((6*ar)/pi);
printf("%.3lf\n",dic);
}
return 0;
}
``````

### Re: 10297

Posted: Fri Dec 05, 2014 2:46 pm
Post in existing thread, use search by problem number (10297).

I think problem is in cbrt function of ANSI C 4.8.2 - GNU C Compiler's library. When you change cbrt to pow judge gives accepted in ANSI C.

Code: Select all

``dic = pow(6 * ar / pi, 1.0 / 3);``

### Re: 10297 - Beavergnaw

Posted: Fri Dec 05, 2014 9:23 pm
Yes, cbrt() is not part of ANSI C, it is returning 1.0 with any argument.