## 10297 - Beavergnaw

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

Moderator: Board moderators

nerocrux
New poster
Posts: 7
Joined: Fri Jul 30, 2004 5:14 am
Location: city of god

### 10297 - Beavergnaw

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

Ghost77 dimen
Learning poster
Posts: 67
Joined: Sun Sep 22, 2002 5:40 am
Location: Taiwan

Try calculus. It's an easy problem.

Good luck.

Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:
You can also use binary search..

nerocrux
New poster
Posts: 7
Joined: Fri Jul 30, 2004 5:14 am
Location: city of god
i see,i'll try,thank u guys!!

nerocrux
New poster
Posts: 7
Joined: Fri Jul 30, 2004 5:14 am
Location: city of god

### 10297 -- need formula

I still cant figur out the formula for this problem.Can anyone give me some hints??THX a lot !!

Frostina
New poster
Posts: 23
Joined: Mon Dec 15, 2003 5:21 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
Thanks for your help !

bonny
New poster
Posts: 3
Joined: Thu Aug 30, 2007 12:31 pm
Location: Dhaka
The formula is:

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

(but i'm still getting WA )

mukit
New poster
Posts: 48
Joined: Wed Nov 21, 2007 10:09 am
Location: Dhaka , Bangladesh
Contact:

### Re: 10297 - Beavergnaw

I don't see any reason of getting W.A.
I used double and solved the problem.

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am

### Re: 10297 - Beavergnaw

For every one getting WA...
Check this point..

Code: Select all

``pi=2*acos(0.0)``
Hope this will solve the problem.
try_try_try_try_&&&_try@try.com
This may be the address of success.

lnr
Experienced poster
Posts: 142
Joined: Sat Jun 30, 2007 2:52 pm

### Re: 10297 - Beavergnaw

Hello,
Can anyone give some hint for this problem?
volume=1/3*(D/2)^2*D

avatar
New poster
Posts: 8
Joined: Wed Nov 16, 2011 6:44 pm

### Re: 10297 - Beavergnaw

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

leo13
New poster
Posts: 1
Joined: Fri Dec 05, 2014 11:25 am

### 10297

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;
}
``````
Last edited by brianfry713 on Fri Dec 05, 2014 9:15 pm, edited 1 time in total.
Reason: Added code blocks

lighted
Guru
Posts: 587
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

### Re: 10297

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);``
A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

### Re: 10297 - Beavergnaw

Yes, cbrt() is not part of ANSI C, it is returning 1.0 with any argument.
Check input and AC output for thousands of problems on uDebug!