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. RSA进阶之两个N的公约数

    适用场景: 给你两个n,n1和n2. 两个数都很大,不好分解. 但是这数刚好有质数公因子(试试欧几里得辗转相除跑完之后,就是不断地相除就可以了,4000多位也是很快的),那不就相当于间接的分解出q或者 ...

  2. JAVA 程序监控基础简述

    最近在项目中自感程序木有问题,也没有什么错误日志出来.但就是有人反映服务慢,有时连不上的情况.为了解决这么妖的问题只能去详细的看看运行中的程序到底出了什么情况,这时如果有个比较好的监控工具可以监控运行 ...

  3. hdu6134[莫比乌斯反演] 2017多校8

    /*hdu6134[莫比乌斯反演] 2017多校8*/ #include <bits/stdc++.h> using namespace std; typedef long long LL ...

  4. Linux(Centos) 搭建ReviewBoard

    一.官方安装手册 reviewboard 的安装用户手册:猛击这里 二.常用安装步骤 2.1.安装httpd,+ mod_wsgi, fastcgi, or mod_python yum -y int ...

  5. nodeJS(2)深了解: nodeJS 项目架构详解(app.js + Express + Http)

    简略了解:nodeJS 深了解(1): Node.js + Express 构建网站预备知识 环境: 环境: win7 + nodeJS 版本(node): 新建 nodeJS 项目: 名称为: te ...

  6. 洛谷P2114起床困难综合征

    从高位到低位按位枚举,贪心.如果该位填1比填0结果优且填1不会超出m限制,那就填1,否则填0 /*by SilverN*/ #include<iostream> #include<c ...

  7. JQuery基础 学习的一些例子以及手册

    原文发布时间为:2009-12-23 -- 来源于本人的百度文章 [由搬家工具导入] 不多说,直接下载。。。 下载:http://www.xmaspx.com/Services/FileAttachm ...

  8. 倒计时浏览器跳转JavaScript

    原文发布时间为:2008-10-11 -- 来源于本人的百度文章 [由搬家工具导入] <html> <head> <title>显示时间</title> ...

  9. .NET发布网站出现了一系列问题(1)---“无法显示XML页”的解决办法

    原文发布时间为:2008-09-11 -- 来源于本人的百度文章 [由搬家工具导入] 原因之一: 这种错误是由asp.net 帐户没有在iis注册造成的。原因可能是.net framework 2.0 ...

  10. About chrysanthemum and matrimony vine

    红枣.枸杞茶:可经常喝. 菊花茶.枸杞茶:适当,一般建议喝3天停3天会比较妥当. 湿热重的人不宜食红枣,可只泡枸杞.菊花或将红枣改为红茶,也能起到明目.养肝.益血.抗疲劳的功效.红枣要去核,才不会太燥 ...