Beavergnaw
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6204   Accepted: 4090

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

简单的数学公式题:细致耐心点就能推出来  圆台的体积为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的更多相关文章

  1. POJ 2405 Beavergnaw (计算几何-简单的问题)

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

  2. poj 2405 Beavergnaw

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

  3. UVa 10297 - Beavergnaw

    题目:假设一个底边与高为D的圆柱切去一部分使得.剩下的中心是底边与高为d的圆柱. 和以他们底面为上下地面的圆锥台,已知切去的体积,求d. 分析:二分,计算几何.圆锥台体积公式:π*(r^2+r*R+R ...

  4. HOJ题目分类

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

随机推荐

  1. MongoDB用PCRE正则表达式

    介绍 下面说明 PCRE 所支持的正则表达式的语法和语义.Perl 文档和很多其它书中也解说了正则表达式,有的书中有很多例子.Jeffrey Friedl 写的“Mastering Regular E ...

  2. koa2在node6中如何运行

    koa2在node6下运行 { "babel-core": "^6.24.1", "babel-plugin-syntax-async-functio ...

  3. Spring MVC请求参数绑定

    所谓请求参数绑定,就是在控制器方法中,将请求参数绑定到方法参数上 @RequestParam 绑定单个请求参数到方法参数上 @RequestParam("id") Integer ...

  4. PIC单片机之时钟设置

    PIC单片机之时钟设置 http://blog.csdn.net/superanters/article/details/8541650 内部时钟和外部时钟? PIC单片机有许多型号可以设置成 用外部 ...

  5. HDU 5875 Function(RMQ-ST+二分)

    Function Time Limit: 7000/3500 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total ...

  6. 0-Broadcast机制原理简要介绍

    Broadcast机制简要介绍 来源: http://blog.csdn.net/luoshengyang/article/details/6730748 导语 广播机制在Android系统中,也不算 ...

  7. vue项目上传文件以及进度条

    最近做项目的时候,需要上传自定义镜像.并且附带进度条,上网查询一下资料,经过一番折磨,也总算做出来了,把自己写项目的内容给大家分享一下. 先直接贴代码吧 1.首先声明一个formData对象. 2.把 ...

  8. 【11】 Express安装入门与模版引擎ejs

    前言 Express简介和安装 运行第一个基于express框架的Web 模版引擎 ejs express项目结构 express项目分析 app.set(name,value) app.use([p ...

  9. hdu 3980 Paint Chain 组合游戏 SG函数

    题目链接 题意 有一个\(n\)个珠子的环,两人轮流给环上的珠子涂色.规定每次涂色必须涂连续的\(m\)颗珠子,无法继续操作的人输.问先手能否赢. 思路 参考 转化 第一个人取完之后就变成了一条链,现 ...

  10. link 和 runtime-link,搭配shared 和 static(转)

    原文转自 http://blog.csdn.net/yasi_xi/article/details/8660549 参考: http://bbs.sjtu.edu.cn/bbscon,board,C, ...