Beavergnaw
来源:互联网 发布:如何保护膝盖关节 知乎 编辑:程序博客网 时间:2024/04/29 12:04
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.
Source: Waterloo Local Contest Jun. 1, 2002
my code :
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI=3.14159265358979323846;
int main(){
double dd,v,d,t;
cin>>dd>>v;
while(!(dd==0&&v==0)){
t=pow(dd,3)-6*v/PI;
d=pow(t,1.0/3);
cout<<setprecision(3)<<fixed;
cout<<d<<endl;
cin>>dd>>v;
}
return 0;
}
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 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.
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: Waterloo Local Contest Jun. 1, 2002
my code :
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
const double PI=3.14159265358979323846;
int main(){
double dd,v,d,t;
cin>>dd>>v;
while(!(dd==0&&v==0)){
t=pow(dd,3)-6*v/PI;
d=pow(t,1.0/3);
cout<<setprecision(3)<<fixed;
cout<<d<<endl;
cin>>dd>>v;
}
return 0;
}
- Beavergnaw
- Beavergnaw
- Beavergnaw
- UVa10297 - Beavergnaw
- POJ Beavergnaw
- POJ2405-Beavergnaw
- fjnu 1527 Beavergnaw
- OJ 1904 Beavergnaw
- FZU 1010 Beavergnaw
- zoj 1904 Beavergnaw
- ZOJ 1904 Beavergnaw
- HOJ 1951 Beavergnaw
- ZOJ 1904 Beavergnaw
- zoj 1904 Beavergnaw
- UVa 10297 - Beavergnaw
- fzuProblem 1010 Beavergnaw
- POJ 2405 Beavergnaw G++
- FZUOJ Problem-1010 Beavergnaw (数学公式水题)
- 在.net中访问硬盘中的.text文件,并用于滚动显示
- KAVA 恩,简单的脚本语言,HOHO
- 短信笑话1-10
- Rotten Ropes
- A DP Problem Asia - Tehran 2003
- Beavergnaw
- javascript正则表达式使用详解
- 在Windows Server下集成Apache、Tomcat和IIS
- mysql语句的批量执行
- acm贴代码了!
- 试下能不能发表
- vista 中网上银行不能用的 bug 解决方案
- SRT字幕文件分割有感
- OSWORKFLOW出书了