fjnu 1527 Beavergnaw

来源:互联网 发布:gta5 handling 数据 编辑:程序博客网 时间:2024/06/02 11:14

Description

When chomping a tree the beaver cuts a very specific shape out of the tree trunk. What is left in the tree trunk looks like two frustums of a cone joined by a cylinder with the diameter the same as its height. A very curious beaver tries not to demolish a tree but rather sort out what should be the diameter of the cylinder joining the frustums such that he chomped out certain amount of wood. You are to help him to do the calculations.

We will consider an idealized beaver chomping an idealized tree. Let us assume that the tree trunk is a cylinder of diameter D and that the beaver chomps on a segment of the trunk also of height D. What should be the diameter d of the inner cylinder such that the beaver chmped out V cubic units of wood?


Input

Input contains multiple cases each presented on a separate line. Each line contains two integer numbers D and V separated by whitespace. D is the linear units and V is in cubic units. V will not exceed the maximum volume of wood that the beaver can chomp. A line with D=0 and V=0 follows the last case.

Output

For each case, one line of output should be produced containing one number rounded to three fractional digits giving the value of d measured in linear units.

Sample Input

10 25020 250025 700050 500000 0

Sample Output

8.05414.77513.11530.901

 

KEY:这题就是推导公式:d=(D^3-6V/PI)^(1/3);要注意的是开三次方时指数要用1/3.0;

 

Source:

#include
<iostream.h>
#include
<math.h>
#define PI 3.1415926
//using namespace std;

double count(double D,double V)
{
    
double t;
    t
=D*D*D-6*V/PI;
    t
=pow(t,1/3.0);
    
return t;
}


int main()
{
//    freopen("fjnu_1527.in","r",stdin);
    double D,V;
    
while(cin>>D>>V&&D!=0&&V!=0)
    
{
        printf(
"%.3f ",count(D,V));
    }

    
return 0;
}