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;
#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;
}
- fjnu 1527 Beavergnaw
- Beavergnaw
- Beavergnaw
- Beavergnaw
- FJNU
- UVa10297 - Beavergnaw
- POJ Beavergnaw
- POJ2405-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++
- 【转.译】关于万向节死锁(Gimbal Lock)
- DataGrid/DataList
- 20080306:上海华为的一道关于指针的编程题目
- fjnu 1382 01000001
- 碎片
- fjnu 1527 Beavergnaw
- 如何给对话框添加背景图片
- struts2整合extremeTable
- 使用内存硬盘--加速系统1
- Linux的poll和select
- Linux设备驱动中的异步操作
- Linux USB驱动中URB的使用
- 经典基础教程---Programming TCP/IP Windows Sockets in C++
- 今天出去逛街了