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. VSTO学习笔记(十四)Excel数据透视表与PowerPivot

    原文:VSTO学习笔记(十四)Excel数据透视表与PowerPivot 近期公司内部在做一种通用查询报表,方便人力资源分析.统计数据.由于之前公司系统中有一个类似的查询使用Excel数据透视表完成的 ...

  2. Deep Learning(深度学习) 学习笔记(四)

    神经概率语言模型,内容分为三块:问题,模型与准则,实验结果.[此节内容未完待续...] 1,语言模型问题 语言模型问题就是给定一个语言词典包括v个单词,对一个字串做出二元推断,推断其是否符合该语言表达 ...

  3. 在 window7 window8下公布webService注意问题

    李石磊 学习日记 错误形如: 解决方式: 1.将服务公布,在IIS下创建虚拟文件夹 2.为上面创建的虚拟文件夹创建单独的应用程序,方法是右击虚拟文件夹.点击"加入应用程序...", ...

  4. mongodb - 前端form表单数据传输,在保存和清除的数据格式的处理程序的 - 非递归

    //处理时间段,将ISODate("2014-10-09T18: 37: 50.0Z") 兑换 2014-10-09 18:37:50这样的格式 //截至处理6层树形结构数据,当多 ...

  5. ORA-16525: the Data Guard broker is not yet available

    DGMGRL> disable configuration;ORA-16525: the Data Guard broker is not yet available Configuration ...

  6. AMDU恢复ASM磁盘组数据(測)

    --umount ASMCMD> umoung -a asmdg commands:         md_backup, md_restor         lsattr, setattr   ...

  7. 一些Android框架

    从网上收集一些框架,敲代码偷懒这些框架非常实用,必须记下来,为了以后少写代码,用别人好的框架 ThinkAndroid ThinkAndroid(一个ThinkAndroid教程地址:http://m ...

  8. 潜水JVM

    原文地址:http://blog.jamesdbloom.com/JVMInternals.html(转载请注明出处和本文地址英文原文) 本文简要解析JVM的内部结构.下图显示了一个典型的一块JVM( ...

  9. WPF 数字小键盘Themes

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x ...

  10. C语言中main函数的參数具体解释

    main函数的定义形式         main函数能够不带參数,也能够带參数,这个參数能够觉得是 main函数的形式參数.C语言规定main函数的參数仅仅能有两个,习惯上这两个參数写为argc和ar ...