POJ2405-Beavergnaw
Time Limit: 1000MS | Memory Limit: 65536K | |
Total Submissions: 6204 | Accepted: 4090 |
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
简单的数学公式题:细致耐心点就能推出来 圆台的体积为V = H*(S^2+s^2+s*S)/3
终于推出 d = (-12.0*v+2*pi*D*D*D)/(2*pi) 的三分之中的一个次方
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
using namespace std;
const double pi = acos(-1.0);
int d,v;
int main(){ while(scanf("%d%d",&d,&v)&&d+v){
double ans = (-12.0*v+2*pi*d*d*d)/(2*pi);
printf("%.3f\n",pow(ans,1.0/3));
}
return 0;
}
POJ2405-Beavergnaw的更多相关文章
- POJ 2405 Beavergnaw (计算几何-简单的问题)
Beavergnaw Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6203 Accepted: 4089 Descri ...
- poj 2405 Beavergnaw
Beavergnaw Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6310 Accepted: 4158 Descri ...
- UVa 10297 - Beavergnaw
题目:假设一个底边与高为D的圆柱切去一部分使得.剩下的中心是底边与高为d的圆柱. 和以他们底面为上下地面的圆锥台,已知切去的体积,求d. 分析:二分,计算几何.圆锥台体积公式:π*(r^2+r*R+R ...
- HOJ题目分类
各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...
随机推荐
- 移动web前端开发小结
注意:Chrome模拟手机的显示的界面是有误差的,强烈建议一定要在真机测试自己的移动端页面(以移动端页面为准). 1.页面高度渲染错误,页面的高度是否包含了导航,(华为手机就是偏偏有底部菜单) 设置窗 ...
- Google Chrome开发者工具-移动仿真:触摸事件仿真
如果你在开发PAD/手机所用WEB版应用,需要在桌面审查页面元素.调试脚本,模拟移动设备尺寸.事件.位置等信息, 那么可以使用Chrome开发者工具(DevTools)提供的强大的移动仿真功能,支持主 ...
- Python学习-day16-DOM
文档对象模型(Document Object Model,DOM)是一种用于HTML和XML文档的编程接口.它给文档提供了一种结构化的表示方法,可以改变文档的内容和呈现方式.我们最为关心的是,DOM把 ...
- python正则表达式应用优化实例
1.问题出现 需要提取一份xml文件中参数名和参数值,格式如下: <p name="actOlLaPdcch">true</p> 我们需要的字段如上,红色部 ...
- editrules
editrules editrules是用来设置一些可用于可编辑列的colModel的额外属性的.大多数的时候是用来在提交到服务器之前验证用户的输入合法性的.比如editrules:{edith ...
- iptables端口转发命令
需求很简单,把本地81端口映射到8080端口上 1. 所有的81请求转发到了8080上. 1 # iptables -t nat -A PREROUTING -p tcp --dport 81 - ...
- mac os 80端口的间接使用
资料显示 MAC OS本质是Unix系统,默认非root用户无法使用1024一下的端口,要是非要用,比如一般情况下,本地项目用tomcat运行,一般都是localhost:8080/XXXX,如果想通 ...
- MacPro 系统空间竟占90G,如何清理--OmniDiskSweeper
MacPro 经常提示我磁盘空间已满,管理磁盘空间. 然后我就管理了一下,发现系统竟占90个G,有点懵逼.然后网上查了资料,发现这个超级好用的工具OmniDiskSweeper. 打开是这样的! 然后 ...
- web.config add handlers and httpmodule to System.Web section.
<?xml version="1.0" encoding="utf-8"?> <!-- For more information on how ...
- [LeetCode] Surrounded Regions 广度搜索
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured ...