题目描述

The WHU ACM Team has a big cup, with which every member drinks water. Now, we know the volume of the water in the cup, can you tell us it height?

The radius of the cup‘s top and bottom circle is known, the cup‘s height is also known.

输入

The input consists of several test cases. The first line of input contains an integer T, indicating the num of test cases. Each test case is on a single line, and it consists of four floating point numbers: r, R, H, V, representing the bottom radius, the top radius, the height and the volume of the hot water. Technical Specification

1. T <= 20.

2. 1 <= r, R, H <= 100; 0 <= V <= 1000,000,000.

3. r <= R.

4. r, R, H, V are separated by ONE whitespace.

5. There is NO empty line between two neighboring cases.

输出

For each test case, output the height of hot water on a single line. Please round it to six fractional digits.

样例输入

1100 100 100 3141562

样例输出

99.999024

提示

 
 
 
 
提说有两种方法 一种二分一种数学求法;
下吗是数学求法:
 

#include<stdio.h>
#include<math.h>
#define PI 3.14159265
int main()
{
int t;
double r,R,H,V,v0,h1;
double ans;
while(scanf("%d",&t)!=EOF)
{
while(t--)
{
scanf("%lf%lf%lf%lf",&r,&R,&H,&V);
if(r!=R)
{
                h1=(R-r)/(H*r)-H;                                             //补全的小圆锥A的高,用相似比算出来
                v0=(PI*r*r*h1)/3;                                             //小圆锥A的体积
               ans=(H+h1)-(H+h1)*pow((((PI*r*r*(H+h1)/3)-V)/(PI*r*r*(H+h1)/3)),1.0/3);     //热水倒入后的体积的高 可以用总的体积减去热血倒入后的体积形成的那个圆锥B与总的补起来后的大圆锥C用相似法比 得出小圆锥B的高   所求的高为大圆锥C高-小圆锥B的高
                
}
else
{
ans=V/(PI*(r*r));
}
if(ans>H) ans=H;
printf("%.6lf\n",ans);
}
}
return 0;
}

poj-2403-cup的更多相关文章

  1. poj 2403

    http://poj.org/problem?id=2403 题意:就是给你m个单词,以及n段对话.每一个单词都有所对应的价值.求对话中的价值总和 题解:很简单,就是用单词和价值对应起来,然后再寻找就 ...

  2. Poj 2403 Hay Points(Map)

    一.题目大意 实现一个工资计算系统.工资的计算规则是:首先,给定一些关键字和对应的价值,这个相对于字典.然后给出的是求职者的描述,如果这个描述中包含关键字则加上对应的价值,总得价值就是这个求职者的工资 ...

  3. POJ 2403 Hay Points

    Hay Points Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5735   Accepted: 3695 Descri ...

  4. Poj 3117 World Cup

    1.Link: http://poj.org/problem?id=3117 2.Content: World Cup Time Limit: 1000MS   Memory Limit: 65536 ...

  5. Poj 1953 World Cup Noise之解题报告

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16369   Accepted: 8095 ...

  6. poj - 1953 - World Cup Noise(dp)

    题意:n位长的01序列(0 < n < 45),但不能出现连续的两个1,问序列有多少种. 题目链接:id=1953" target="_blank">h ...

  7. POJ 1953 World Cup Noise

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14397   Accepted: 7129 ...

  8. poj 1953 World Cup Noise (dp)

    World Cup Noise Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16774   Accepted: 8243 ...

  9. POJ 1953 World Cup Noise(递推)

    https://vjudge.net/problem/POJ-1953 题意:输入一个n,这n位数只由0和1组成,并且不能两个1相邻.计算共有多少种排列方法. 思路:递推题. 首先a[1]=2,a[2 ...

  10. POJ 题目分类(转载)

    Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...

随机推荐

  1. 第四课 Grid Control实验 安装JCH2库并且配置好监听,关键步骤和结果截图

      --从OCM 虚拟机中,克隆了安装oracle之前的状态 配置网络: [root@localhost network-scripts]# ifup ifcfg-eth0 [root@localho ...

  2. iPhone6设计自适应布局

    http://www.devtalking.com/articles/adaptive-layout-for-iphone6-1/ http://www.devtalking.com/articles ...

  3. automaticallyAdjustsScrollViewInsets的作用

    简单点说就是automaticallyAdjustsScrollViewInsets根据按所在界面的status bar,navigationbar,与tabbar的高度,自动调整scrollview ...

  4. jxl读和取Excel文件

    请参看下面链接: jxl如何读和取excle中的数据

  5. Spring HibernateTemplate的使用

    Spring HibernateTemplate的使用 2008-03-25 11:38 2020人阅读 评论(0) 收藏 举报 springbeanhibernatesessiondaoclass ...

  6. 2013年9月份阿里JAVA面试经历

    面试时间:2013-9 面试地点:合工大 面试内容: 1. struts2怎么实现的,原理是什么 2. session是怎么实现的?存储在哪里? 3. Java怎么创建链表的? 定义一个结点类,再定义 ...

  7. HDU 1172 猜数字(DFS)

    猜数字 Time Limit:10000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  8. mvn打包发布

    一:打包 cmd进入工作目录运行命令 1: mvn clean 2: mvn install  3: mvn clean compile    4: mvn package -DiskipTest  ...

  9. KEIL CRACK及 0xFD Bug修正方法

    0xFD Bug是keil编译器中始终存在,而又从未得到官方修复的一个BUG!!! BUG描述:当C源代码中使用了汉字等非ASCII字符,而此字符的编码又恰好包含了大于或等于0xFD的字节时,这个字节 ...

  10. 激活前一个程序(注册全局消息,使用Mutex探测,如果已经占用就广播消息通知第一个程序,然后第一个程序做出响应)

    unit MultInst; interface const MI_QUERYWINDOWHANDLE = ; MI_RESPONDWINDOWHANDLE = ; MI_ERROR_NONE = ; ...