Beavergnaw
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6203   Accepted: 4089

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 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 (计算几何-简单的问题)的更多相关文章

  1. poj 2405 Beavergnaw

    Beavergnaw Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6310   Accepted: 4158 Descri ...

  2. 2018.07.04 POJ 1654 Area(简单计算几何)

    Area Time Limit: 1000MS Memory Limit: 10000K Description You are going to compute the area of a spec ...

  3. 2018.07.04 POJ 3304 Segments(简单计算几何)

    Segments Time Limit: 1000MS Memory Limit: 65536K Description Given n segments in the two dimensional ...

  4. poj 1687 Buggy Sat 简单计算几何

    暑期集训出的第一道一血 感觉自己萌萌哒…… 这道题本身并没有坑点 仅仅是翻译巨坑…… 解大腿在做B 安学长在做E 我闲着也没事 就一个词一个词翻译F…… 最后感觉…… 题干大多数都看不懂…… 也都没啥 ...

  5. POJ 1163 The Triangle(简单动态规划)

    http://poj.org/problem?id=1163 The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissi ...

  6. hdu 4720 计算几何简单题

    昨天用vim练了一道大水题,今天特地找了道稍难一点的题.不过也不是很难,简单的计算几何而已.练习用vim编码,用gdb调试,结果居然1A了,没调试...囧... 做法很简单,无非就是两种情况:①三个巫 ...

  7. POJ 2406 Power Strings 简单KMP模板 strcmp

    http://poj.org/problem?id=2406 只是模板,但是有趣的是一个strcmp的字符串比较函数,学习到了... https://baike.baidu.com/item/strc ...

  8. POJ 1844 Sum【简单数学】

    链接: http://poj.org/problem?id=1844 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=29256#probl ...

  9. A - TOYS(POJ - 2318) 计算几何的一道基础题

    Calculate the number of toys that land in each bin of a partitioned toy box. 计算每一个玩具箱里面玩具的数量 Mom and ...

随机推荐

  1. 属性“dataProvider”有多个初始值设定项。(注意:“dataProvider”是“mx.charts.BarChart”的默认属性)。

    1.错误描写叙述 属性"dataProvider"有多个初始值设定项.(注意:"dataProvider"是"mx.charts.BarChart&q ...

  2. redis优化配置和redis.conf说明

    1. redis.conf 配置參数: #是否作为守护进程执行 daemonize yes #如以后台进程执行,则需指定一个pid,默觉得/var/run/redis.pid pidfile redi ...

  3. C# 开发Chrome内核浏览器(WebKit.net)

    原文地址:http://www.cnblogs.com/linyijia/p/4045333.html

  4. jquery ui中 accordion的问题及我的解决方法

    原文:jquery ui中 accordion的问题及我的解决方法 jquery有一套所谓的ui组件,很不错的.如果有兴趣的朋友,可以参考http://jqueryui.com/ 但其中的accord ...

  5. Android的内存优化

    腾讯公司在五月三十一日开展[腾讯Bugly移动开发人员沙龙]大会.大会上面叶方正老师解说了 关于Android的内存优化的问题,只是我感觉叶老师许多其它的站在了測试的角度上去解释了这一方面,叶老师给我 ...

  6. 约瑟夫问题--list模拟循环链表

    约瑟夫问题 Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 n个人想玩残酷的死亡游戏,游戏规则例如以下: n个人进行编号,分别 ...

  7. 啊上班我排名可人皮号i家狂喷

    http://pan.baidu.com/share/link?shareid=3011665141&uk=338692646&third=15                http ...

  8. 牛逼的验证码,printf返回值

    牛逼的验证码,如下图, 结果是4321,为什么呢,主要是printf返回值问题?那么printf到底返回什么? 经查阅,printf的返回值是打印的字符个数,因此结果是4321就很明显了.

  9. java中HashMap在多线程环境下引起CPU100%的问题解决(转)

    最近项目中出现了Tomcat占用CPU100%的情况,原以为是代码中出现死循环,后台使用jstack做了dump,发现是系统中不合理使用HashMap导致出现了死循环(注意不是死锁). 产生这个死循环 ...

  10. android_重写button样式

    这样的button样式应该源自IOS.假设安卓上实现,则须要使用android上面的layer-list来实现. 事实上layer-list有点像framlayout,作用就是覆盖. 先说一下实现原理 ...