POJ 2405 Beavergnaw (计算几何-简单的问题)
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6203 | Accepted: 4089 |
Description


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
line with D=0 and V=0 follows the last case.
Output
Sample Input
10 250
20 2500
25 7000
50 50000
0 0
Sample Output
8.054
14.775
13.115
30.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
Beavergnaw Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6310 Accepted: 4158 Descri ...
- 2018.07.04 POJ 1654 Area(简单计算几何)
Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...
- 2018.07.04 POJ 3304 Segments(简单计算几何)
Segments Time Limit: 1000MS Memory Limit: 65536K Description Given n segments in the two dimensional ...
- poj 1687 Buggy Sat 简单计算几何
暑期集训出的第一道一血 感觉自己萌萌哒…… 这道题本身并没有坑点 仅仅是翻译巨坑…… 解大腿在做B 安学长在做E 我闲着也没事 就一个词一个词翻译F…… 最后感觉…… 题干大多数都看不懂…… 也都没啥 ...
- POJ 1163 The Triangle(简单动态规划)
http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissi ...
- hdu 4720 计算几何简单题
昨天用vim练了一道大水题,今天特地找了道稍难一点的题.不过也不是很难,简单的计算几何而已.练习用vim编码,用gdb调试,结果居然1A了,没调试...囧... 做法很简单,无非就是两种情况:①三个巫 ...
- POJ 2406 Power Strings 简单KMP模板 strcmp
http://poj.org/problem?id=2406 只是模板,但是有趣的是一个strcmp的字符串比较函数,学习到了... https://baike.baidu.com/item/strc ...
- POJ 1844 Sum【简单数学】
链接: http://poj.org/problem?id=1844 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29256#probl ...
- A - TOYS(POJ - 2318) 计算几何的一道基础题
Calculate the number of toys that land in each bin of a partitioned toy box. 计算每一个玩具箱里面玩具的数量 Mom and ...
随机推荐
- 【C#遗补】获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPath的区别
原文:[C#遗补]获取应用程序路径之System.IO.Directory.GetCurrentDirectory和System.Windows.Forms.Application.StartupPa ...
- Android入门之简单短信发送器
效果图: manifest.xml 文件中加入 <uses-permission android:name="android.permission.SEND_SMS"/&g ...
- BASH Shell 简易进度条小函数
不多说,直接上脚本. # processbar <current> <total> processbar() { local current=$1; local total=$ ...
- three.js是JavaScript编写的WebGL第 三方库
three.js是JavaScript编写的WebGL第 三方库.提供了非常多的3D显示功能.Three.js 是一款运行在浏览器中的 3D 引擎,你可以用它创建各种三维场景,包括了摄影机.光影.材质 ...
- 【转向Javascript系列】深入理解Generators
随着Javascript语言的发展,ES6规范为我们带来了许多新的内容,其中生成器Generators是一项重要的特性.利用这一特性,我们可以简化迭代器的创建,更加令人兴奋的,是Generators允 ...
- android app崩溃日志收集以及上传
源代码获取请到github:https://github.com/DrJia/AndroidLogCollector 已经做成sdk的形式,源代码已公开,源代码看不懂的请自行google. 假设想定制 ...
- 视频编解码器,bbv 缓冲区溢出和下溢
使用硬件相似数据处理.数据通常未来,形式的处理后,立即出动.所以,一般有一个数据馈送,数据输出,2接口. 实时硬件处理的基本要求.进来的数据,紧接着治疗头发治疗,这需要在很短的时间,好多毫秒以内,才干 ...
- Mercurial简介
前言 目前所在的公司的版本控制使用的是Mercurial,它也有一个对应的客户端小乌龟,但是Mercurial跟我们之前使用的SVN有着本质的区别,对于其区别会在下一篇中介绍到,这次主要是带领 ...
- C++ Primer 学习笔记_57_类和数据抽象 --管理指针成员
复印控制 --管理指针成员 引言: 包括指针的类须要特别注意复制控制.原因是复制指针时.一个带指针成员的指针类 class HasPtr { public: HasPtr(int *p,int i): ...
- FZUOJ Problem 2178 礼品配送
Problem 2178 礼物分配 题目链接: Click Here~ Problem Description 在双胞胎兄弟Eric与R.W的生日会上,他们共收到了N个礼物,生日过后他们决定分配这N个 ...