zoukankan      html  css  js  c++  java
  • poj 2405 Beavergnaw

    Beavergnaw
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 6310   Accepted: 4158

    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 250
    20 2500
    25 7000
    50 50000
    0 0
    

    Sample Output

    8.054
    14.775
    13.115
    30.901
    

    Source

    分析:

    数学题

     1 #include<iostream>
     2 #include<queue>
     3 #include<cstdio>
     4 #include<cstring>
     5 #include<cmath>
     6 using namespace std;
     7 #define pi 3.1415926
     8 int main(){
     9     double d,v;
    10     while(cin>>d>>v){
    11         if(d==0&&v==0){
    12             break;
    13         }
    14         double a=d*d*d-6.0*v/pi;
    15         a=pow(a,1.0/3);
    16         printf("%.3f
    ",a); //写成printf("%.3lf
    ",a);是错的
    17 }
    18return0;
    19 }
  • 相关阅读:
    【Spring-MVC】
    【多线程】线程池关闭
    【DDD】基于事件驱动EDA -- 待完成
    【DDD】编码实战
    【Elastic Search】01- 原理
    【DDD】基于DDD的分层设计
    【DDD】Thoughtworks笔记(编码样例) -- 未完成
    【DDD】Thoughtworks笔记(目录划分、异常设计)
    平方和求余
    Factoring a Polynomial
  • 原文地址:https://www.cnblogs.com/Deribs4/p/4283178.html
Copyright © 2011-2022 走看看