题目描述

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. Unix is 命令

    输入正整数n以及n个文件名,排序后按列优先的方式左对齐输出.假设最长文件名有M字符,则最右列有M字符,其他列都是M+2字符. 附加条件每行最多输出60个字符,在此条件下要求行最少. Sample in ...

  2. (a*b)%c 问题

    给你两个数__int64 类型的整数 a ,b,c.问你,(a*b)%c的值是多少??我们知道: (a*b)%c = ((a%c)*(b%c))%c .不过即使这样做,在c很大的情况下,(a%c)*( ...

  3. CDZSC_2015寒假新人(2)——数学 A

    A - A Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status ...

  4. VS2010无法断点调试解决办法

    今天我的VS2010忽然出现设置断点的时候,无法进行调试.现象:每次在设置断点调试的时候都会出现卡机,然后VS弹出如下图所示的状况: 解决办法: 依次点击:“工具-->扩展管理器”然后找到.Ne ...

  5. struts2的注解配置全面解析

    以前在用struts2的注解配置时总是要在web.xml中配置一个初始化参数(actionPackages),最近发现不灵了,仔细研究了下发现即使不用在web.xml中配置也能成功,但时灵时不灵的,很 ...

  6. 视听说加速器--AHK辅助工具

    大学有视听说这门课,看起来这门课设计得非好,可是对大多数人来讲却不能按时完成.到了最后都要抓紧提速,上网找答案,辛苦的抄,有“聪明者”便找加速器来做. 我也是赶着做的人之一.抄答案太累,加速器太卡,还 ...

  7. innobackupex 使用说明

    1.创建备份相关用户 '; grant reload,lock tables,replication client,process,super on *.* to 'backuper'@'127.0. ...

  8. debian gnome 3插件

    1.gnome 配置-安装插件 http://maxubuntu.blogspot.com/2012/09/debian-gnome3.html hunagqf|hunaqf2|hunaqf3 2.快 ...

  9. Nginx限制模块研究

    已有方案:无非两种 1. 限制连接个数: 是指一台机多线程或多进程开启请求. 解决方案-ngx_http_limit_conn_module 缺点: 定义$variable为单机时,只能限制已有ngi ...

  10. javascript prototype __proto__区别

    An Object's __proto__ property references the same object as its internal [[Prototype]] (often refer ...