POJ 2405 Beavergnaw (计算几何-简单题)
来源:互联网 发布:matlab 关联矩阵代码 编辑:程序博客网 时间:2024/05/28 16:03
Description
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
Output
Sample Input
10 25020 250025 700050 500000 0
Sample Output
8.05414.77513.11530.901
Source
题目大意:告诉你圆柱直径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 G++
- POJ 1106 Transmitters (简单计算几何)
- POJ 2624 简单计算几何
- POJ 1675 简单计算几何
- POJ Beavergnaw
- poj 计算几何题全集(转)
- poj 题目2398 Toy Storage (简单计算几何)
- POJ 2850 Stacking Cylinders 简单计算几何
- poj 1113 凸包+简单几何计算
- POJ 1269 Intersecting Lines 简单计算几何
- poj计算几何题推荐
- poj 2398 (计算几何)
- poj 2318(计算几何)
- poj 1039(计算几何)
- poj 1408(计算几何)
- POJ 3347(计算几何)
- POJ2318 计算几何简单题
- uninstall app
- T-SQL查询进阶--深入浅出视图
- hdu1251
- 2rrtuiiu
- [cocos2d-x]屏幕自适应解决办法
- POJ 2405 Beavergnaw (计算几何-简单题)
- C语言堆栈入门——堆和栈的区别
- VC中如何调用其他的可执行程序
- 指针知识梳理3-指针作为参数
- windows cygwin安装git
- VMware设置桥接上网
- 游戏暂停带来了什么?
- WPF程序矢量的条码生成控件Barcode Professional for WPF
- POJ2405-Beavergnaw