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. C++ STL map容器的说明测试1

    // maptest.cpp : 定义控制台应用程序的入口点.// #include "stdafx.h" /*********************************** ...

  2. php字符串 函数

    strtolower()//字符串转化小写的字母 $str="abcdEfG";$s=strtolower($str); 输出:abcdefg; strtoupper();字符串转 ...

  3. 深入学习之mysql(四)聚合函数

    聚合函数:COUNT统计记录的条数.SUM求和函数.AVG求平均值.MAX求最大值.MIN求最小值   一.COUNT练习: 1.统计学校一共有多少个学生: mysql> SELECT COUN ...

  4. C#知识点<4>

    1\C# 运算符重载 您可以重定义或重载 C# 中内置的运算符.因此,程序员也可以使用用户自定义类型的运算符.重载运算符是具有特殊名称的函数,是通过关键字 operator 后跟运算符的符号来定义的. ...

  5. Python的生成器Generator小结

    一. 生成器的介绍 在介绍生成器(Generator)之前,我们首先需要熟悉列表生成式,列表生成式是Python内置的简单又强大的用来创建列表的生成式. 举个例子, 如果我们想生成[1*1,2*2,3 ...

  6. 【Begin】

    迫于无奈,我想提高写博速度.我要尽量压缩每道题的题解思路.最终我选择背叛大米兔,但是我支持它.因为它的每一篇博客耗时巨大,精贵的竞赛集训时间经不起它花:可同时精致的博客会带给来浏览的Oier们更多东西 ...

  7. webpack 样式模块打包深入学习

    1. style-loader css-loader sass-loader 分别的作用 style-loader: 将所有的样式嵌入到dom的style属性当中. css-loader: 将css当 ...

  8. 部署私有Docker Registry

    安装部署一个私有的Docker Registry是引入.学习和使用Docker这门技术的必经之路之一.尤其是当Docker被所在组织接受,更多人.项目和产品开始接触和使用Docker时,存储和分发自制 ...

  9. 如何在MySQL中导入大容量SQL文件

    在实际工作中,有时需要导入大容量sql文件到MySQL,通常有以下三种方法: (1)通过phpmyadmin,不推荐,有内存等的限制: (2)通过Navicat Premium工具运行sql,不推荐, ...

  10. Codevs 1315 摆花

    1315 摆花 2012年NOIP全国联赛普及组 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 黄金 Gold 题目描述 Description 小明的花店新开张,为了吸引顾客,他 ...