HDUOJ-------2493Timer(数学 2008北京现场赛H题)

Timer


Time
Limit: 2000/1000 MS (Java/Others)    Memory Limit:
32768/32768 K (Java/Others) Total Submission(s):
445    Accepted Submission(s): 90

Problem Description

Recently, some archaeologists discovered an ancient relic
on a small island in the Pacific Ocean. In the relic, they found an interesting
cone shaped container with transparent bottom. The container lay on the
horizontal ground with its central axis parallel to the ground. Just beside the
container, they found a manual telling them something about the container. 
The container was a timer for a
special ceremony. Ancient people filled it all with water before the ceremony,
and when the ceremony began, they pulled out the plug in the small hole on the
tip of the cone to let the water out. There was a horizontal line called “sacred
line” carved on the bottom of the cone, and when the water level hit that line,
they pushed the plug back and ended the ceremony. But the archaeologists could
not found the sacred line on that cone. In order to sell the timer at a good
prize, the archaeologists wanted to recover that very important line. 
By the manual they figured out
how much water flew out when the ceremony ended, but they don’t know what to do
next, so they come to you for help. 
They measures the height of the
cone, and the diameter of the bottom, you should tell them the sacred line’s
height above the ground. 

Input

The first line of the input contains an integer
T(1<=T<=20), indicating the number of test cases.
Each line after that
is a test case. It contains three real numbers, H, D(1<=H,D<=1000) and V,
indicating the height and bottom diameter of the timer, and the volume of water
that flew out during the ceremony. That volume is guaranteed to be less than
half volume of the container.

Output

For each test case, output one line containing the height
of the sacred line above the ground.
You should round off the answers to the
5th decimal place. (For example, rounding off 4.000005 equals to 4.00001 and
rounding off 4.000004 equals to 4.00000)

Sample Input

2 5.0 10.0 0.0 5.0
10.0 65.4498

Sample Output

10.00000 5.00000

Source

2008
Asia Regional Beijing

数学题: 看了结题报告做的

代码:

 1 #include<stdio.h>
2 #include<stdlib.h>
3 #include<math.h>
4 const double ZERO =1e-8 ;
5 double H,D,V,R;
6 double calc(double r)
7 {
8 double h=R-r;
9 return H*R*R*acos(h/R)/3 -h*H*sqrt(R*R-h*h)*2/3+h*h*h*H/R*log((R+sqrt(R*R-h*h))/h)/3;
10 }
11 int main()
12 {
13 int cases =0;
14 double l,r,mid;
15 scanf("%d",&cases);
16 while(cases--)
17 {
18 scanf("%lf%lf%lf",&H,&D,&V);
19 R=D/2.0;
20 l=0; r=R;
21 while(r-l>=ZERO)
22 {
23 mid=(l+r)/2;
24 if(calc(mid)<V) l=mid;
25 else r=mid;
26 }
27 printf("%.5lf\n",2*R-(l+r)/2.0);
28 }
29 return 0;
30 }

HDUOJ-------2493Timer(数学 2008北京现场赛H题),布布扣,bubuko.com

时间: 2024-08-24 23:04:45

HDUOJ-------2493Timer(数学 2008北京现场赛H题)的相关文章

HDUOJ--------A simple stone game(尼姆博弈扩展)(2008北京现场赛A题)

A simple stone game                                                                                                       Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)                                             

HDU 5119 Happy Matt Friends(2014北京区域赛现场赛H题 裸背包DP)

虽然是一道还是算简单的DP,甚至不用滚动数组也能AC,数据量不算很大. 对于N个数,每个数只存在两个状态,取 和 不取. 容易得出状态转移方程: dp[i][j] = dp[i - 1][j ^ a[i]] + dp[i - 1][j]; dp[i][j] 的意思是,对于数列 中前 i 个数字,使得 XOR 和恰好为 j 的方案数 状态转移方程中的 dp[i - 1][j] 即表示当前这个数字不取, dp[i - 1][j ^ a[i]] 表示当前这个数字要取. 这道题还是要好好理解阿! sou

Hihocoder 1634 Puzzle Game(2017 ACM-ICPC 北京区域赛 H题,枚举 + 最大子矩阵变形)

题目链接  2017 Beijing Problem H 题意  给定一个$n * m$的矩阵,现在可以把矩阵中的任意一个数换成$p$,求替换之后最大子矩阵的最小值. 首先想一想暴力的方法,枚举矩阵中的数,然后$O(n^{3})$求最大子矩阵更新答案,这样复杂度是$O(n^{5})$的. 思考得再仔细一些,就是包含这个数的最大子矩阵和,以及不包含这个数的最大子矩阵的和的较大值. 设原矩阵中最大子矩阵和为$mx$. 设$u_{i}$为只考虑矩阵前$i$行的最大子矩阵和,$d_{i}$为考虑矩阵第$

HDU 4427 Math Magic (2012年长春现场赛H题)

1.题目描述:点击打开链接 2.解题思路:本题要求寻找k个正整数,它们的和恰好是N,它们的LCM恰好是M的解的个数.可以设置一个三维的dp来解决.用dp(i,j,k)表示选择i个数,它们的和恰好是j,它们的LCM恰好是k的个数.那么答案就是dp(k,n,m).不过这里介绍一种利用状态压缩思想求解的方法. 通过题意可以发现,N,M的范围都比较小,不超过1000,而1000之内的所有数的不同素因子的种类数目不超过4个,这是因为2*3*5*7<1000,而2*3*5*7*11>1000.考虑到素因子

2014鞍山现场赛H题HDU5077(DFS减枝+打表)

NAND Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) Total Submission(s): 65    Accepted Submission(s): 14 Problem Description Xiaoqiang entered the "shortest code" challenge organized by some self-claimed a

hdu 4438 第37届ACM/ICPC 天津赛区现场赛H题

题意:Alice和Bob两个人去打猎,有两种(只)猎物老虎和狼: 杀死老虎得分x,狼得分y: 如果两个人都选择同样的猎物,则Alice得分的概率是p,则Bob得分的概率是(1-p): 但是Alice事先知道Bob先选老虎的概率是Q,问Alice得分的期望最大值是 求期望 如果先去打老虎,则会有bob先去打狼和bob去打老虎两种情况,期望相加则是alice去打老虎的期望,然后求打狼的期望,比较大小即可 1 #include<cstdio> 2 #include<iostream> 3

hdu 4089 不错的DP 北京现场赛题

http://acm.hdu.edu.cn/showproblem.php?pid=4089 还有疑惑,需要重新推: 但是学到的: 1.A=a+b+c  abc是三种情况,那么P(A)=a*P(a->事件)+b*P(b->事件)+c*P(c->事件); a->事件意思是 在a情况下的事件,就是全概率公式的思想吧 2.一定注意每一步会不会出现分母为0 的情况,以及预处理的时候对于一些特殊情况导致自己的式子会出现分母为0的排除掉 3.概率DP经常出现推出了式子但是自己不会写代码的情况,

zoj 3819(牡丹江现场赛A题)

马上要去上海了,刷刷现场赛的题找找感觉~~~ 这题.......额,没什么好说的,太水.. ZOJ Problem Set - 3819 Average Score Time Limit: 2 Seconds      Memory Limit: 65536 KB Bob is a freshman in Marjar University. He is clever and diligent. However, he is not good at math, especially in Mat

2015北京网络赛A题The Cats&#39; Feeding Spots

题意:给你一百个点,找个以这些点为中心的最小的圆,使得这个圆恰好包含了n个点,而且这个圆的边界上并没有点 解题思路:暴力枚举每个点,求出每个点到其他点的距离,取第n大的点,判断一下. 1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 #include<iostream> 5 #include<memory.h> 6 using namespace std; 7 const i