题目描述

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. React-Native做一个文本输入框组件

    我又回来啦! 由于最近一直在做公司的项目,而且比较急.如今项目已经迭代到第三期,可以缓一缓了... 说实话,最近一直再用android做开发,而且时间也不宽裕,react-native有点生疏了. 好 ...

  2. iOS-tableView点击下拉菜单

    #import "ViewController.h" @interface ViewController ()<UITableViewDataSource,UITableVi ...

  3. A Bit Of Knowledge

    iOS推崇使用png格式的图片,说这样不会失帧 imageNamed 和 imageWithContentOfFile的区别 imageNamed会使用系统缓存,对重复加载的图片速度会快一些,效果好. ...

  4. uva 508 Morse Mismatches

    Samuel F. B. Morse is best known for the coding scheme that carries his name. Morse code is still us ...

  5. Java异常基础Exception

    异常指不期而至的各种状况,如:文件找不到.网络连接失败.非法参数等.异常是一个事件,它发生在程序运行期间,干扰了正常的指令流程.Java通 过API中Throwable类的众多子类描述各种不同的异常. ...

  6. 单机/伪分布式Hadoop2.4.1安装文档

    转载自官方文档,最新版请见:http://hadoop.apache.org/docs/r2.4.1/hadoop-project-dist/hadoop-common/SingleCluster.h ...

  7. java读取xml(当xml放在包里时)

  8. BZOJ 1064 假面舞会

    http://www.lydsy.com/JudgeOnline/problem.php?id=1064 思路:第一眼看的时候以为是差分约束,但是是做不了的,不过能保证的就是这题绝对是图论题...(废 ...

  9. 互斥体与互锁 <第五篇>

    互斥体实现了“互相排斥”(mutual exclusion)同步的简单形式(所以名为互斥体(mutex)).互斥体禁止多个线程同时进入受保护的代码“临界区”.因此,在任意时刻,只有一个线程被允许进入这 ...

  10. codeforce343A

    题目地址:http://codeforces.com/problemset/problem/343/A 比赛的时候就囧了,只推出a<b的时候最少需要b个电阻. 后来看了题解,知道 题意:用最少的 ...