zoukankan      html  css  js  c++  java
  • POJ2405-Beavergnaw

    Beavergnaw
    Time Limit: 1000MS   Memory Limit: 65536K
    Total Submissions: 6204   Accepted: 4090

    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
    
    
    简单的数学公式题:细致耐心点就能推出来  圆台的体积为V = H*(S^2+s^2+s*S)/3
    终于推出 d = (-12.0*v+2*pi*D*D*D)/(2*pi) 的三分之中的一个次方
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <vector>
    #include <string>
    #include <algorithm>
    #include <queue>
    #include <cmath>
    using namespace std;
    const double pi = acos(-1.0);
    int d,v;
    int main(){
    
        while(scanf("%d%d",&d,&v)&&d+v){
            double ans = (-12.0*v+2*pi*d*d*d)/(2*pi);
            printf("%.3f
    ",pow(ans,1.0/3));
        }
        return 0;
    }
    


    
       
    
  • 相关阅读:
    【WPF】【基础】布局系统
    【设计】【托管扩展性框架】 MEF vs 2010 samples
    【wpf】【控件】内容控件
    【Wpf】【debug】Exception has been thrown by the target of an invocation.
    【设计模式】概述
    期待与悲催中的2012
    金额转为大写人民币
    使用vs2005的GridView控件,菜鸟问题。
    Microsoft Visual Studio 2005中使用水晶报表
    将金额小写转化成汉字大写(javascript)
  • 原文地址:https://www.cnblogs.com/cynchanpin/p/6805354.html
Copyright © 2011-2022 走看看