POJ 2405 Beavergnaw (计算几何-简单题)
2014-06-20 15:15
429 查看
Beavergnaw
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
Sample Output
Source
Waterloo local 2002.07.01
题目大意:告诉你圆柱直径D,以及啃掉的面积V, 求d
解题思路:
简单的几何问题,够造体积相等,求未知数
V=直径为D的圆柱的体积-两个园台的体积-直径为d的圆柱的体积。
圆台体积公式 = 1/3* pi * (r1*r1 + r2*r2 + r1*r2)*h r1,r2,h分别为圆台上低半径、下底半径和高
V=pi*(D/2)*(D/2)*D - 1/3 *( D*s1-d*s2 ) - pi*(d/2)*(d/2)*d
V=pi*(D/2)*(D/2)*D - 1/3 *pi( D*D/4 + d*d/4 + D*d/4 )*( (D-d)/2) - pi*(d/2)*(d/2)*d
V=pi*D*D*D/4 - 1/3 *pi( D*D/4 + d*d/4 + D*d/4 )*(D/2 - d/2 ) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D + d*d + D*d )*(D - d ) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D *D+ d*d*D + D*d*D - D*D*d - d*d*d - D *d *d) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D *D - d*d*d) - pi*d*d*d/4
V=pi*D*D*D/6 - pi*d*d*d/6
d*d*d = D*D*D - 6*V/pi
d=( D*D*D - 6*V/pi )^(1/3)
解题代码:
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6203 | Accepted: 4089 |
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
Waterloo local 2002.07.01
题目大意:告诉你圆柱直径D,以及啃掉的面积V, 求d
解题思路:
简单的几何问题,够造体积相等,求未知数
V=直径为D的圆柱的体积-两个园台的体积-直径为d的圆柱的体积。
圆台体积公式 = 1/3* pi * (r1*r1 + r2*r2 + r1*r2)*h r1,r2,h分别为圆台上低半径、下底半径和高
V=pi*(D/2)*(D/2)*D - 1/3 *( D*s1-d*s2 ) - pi*(d/2)*(d/2)*d
V=pi*(D/2)*(D/2)*D - 1/3 *pi( D*D/4 + d*d/4 + D*d/4 )*( (D-d)/2) - pi*(d/2)*(d/2)*d
V=pi*D*D*D/4 - 1/3 *pi( D*D/4 + d*d/4 + D*d/4 )*(D/2 - d/2 ) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D + d*d + D*d )*(D - d ) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D *D+ d*d*D + D*d*D - D*D*d - d*d*d - D *d *d) - pi*d*d*d/4
V=pi*D*D*D/4 - 1/24 *pi( D*D *D - d*d*d) - pi*d*d*d/4
V=pi*D*D*D/6 - pi*d*d*d/6
d*d*d = D*D*D - 6*V/pi
d=( D*D*D - 6*V/pi )^(1/3)
解题代码:
#include <iostream> #include <cmath> #include <cstdio> using namespace std; const double pi=acos(double(-1)); int main(){ int d,v; while(cin>>d>>v && (d||v) ){ double D=(double)d,V=(double)v; double tmp=D*D*D-6*V/pi; printf("%.3f\n",pow(tmp,1.0/3.0)); } return 0; }
相关文章推荐
- POJ 2405 Beavergnaw (计算几何-简单的问题)
- POJ 2405 Beavergnaw (计算几何-简单题)
- POJ 2624 简单计算几何
- poj 1556 简单计算几何+简单图论
- poj 题目2398 Toy Storage (简单计算几何)
- POJ 1269 Intersecting Lines 简单计算几何
- POJ2405-Beavergnaw
- POJ 1264 UVA 109 简单的计算几何
- POJ 1106 Transmitters (简单计算几何)
- POJ 1269(计算几何初步——简单处理解析几何,求直线交点)
- POJ 1675 简单计算几何
- POJ 1269 Intersecting Lines(简单计算几何,判断直线的关系)
- poj 1113 凸包+简单几何计算
- POJ 2405 Beavergnaw G++
- POJ 4048 Chinese Repeating Crossbow 简单计算几何
- POJ 2850 Stacking Cylinders 简单计算几何
- poj1410 简单计算几何
- ●POJ 1556 The Doors(简单计算几何+最短路)
- poj 2405 Beavergnaw
- 计算几何:极角排序(poj 2007 Scrambled Polygon)与简单凸包(poj 1113 Wall)