UVALIVE 4330 Timer
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.
<tex2html_verbatim_mark>Input
The first line of the input contains an integer T<tex2html_verbatim_mark>(1
T
20)<tex2html_verbatim_mark> , indicating the number of test cases. Each line after that is a test case. It contains three real numbers, H<tex2html_verbatim_mark> , D<tex2html_verbatim_mark>(1
H, D
1000)<tex2html_verbatim_mark> and V<tex2html_verbatim_mark> , 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)
Hint: Here are some formulas you may need. Please notice that in these formulas, Log means log e<tex2html_verbatim_mark> or ln.

dx =
x
-
a2Log[x +
] + C<tex2html_verbatim_mark>

dx =
x
+
a2Log[x +
] + C<tex2html_verbatim_mark>

dx =
(x
+ a2ArcTan[
]) + C<tex2html_verbatim_mark>
Log[a +
]dx = a ArcTan[
] + x(- 1 + Log[a +
]) + C<tex2html_verbatim_mark>
xLog[a +
]dx =
(a2 - x2 -2a
+2x2Log[a +
]) + C<tex2html_verbatim_mark>
x2Log[a +
]dx =
(- 2x3 -3ax
+3a3ArcTan[
] + 6x3Log[a +
]) + C<tex2html_verbatim_mark>
Sample Input
2
5.0 10.0 0.0
5.0 10.0 65.4498
Sample Output
10.00000
5.00000 二分解决 就是积分这个体积我自己没挤出来看了别人的代码。直接粘过来了记录一下 二分还是比较容易理解的
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <stack>
#include <queue>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define PI 3.1415926535897932626
using namespace std;
int gcd(int a, int b) {return a % b == 0 ? b : gcd(b, a % b);}
int main()
{
double r,h,ans,v;
while (cin >> r >> h)
{
v = 2 * r * r * PI * h;
if (r * 2 > h)
{
double temp = sqrt(r * r - h * h / 4);
ans = temp * h * h / 4 + r * r * r * 2 / 3 - r * r * temp + temp * temp * temp / 3;
}
else
ans = r * r * r * 2 / 3;
printf("%.4lf\n",v - ans * 8);
}
return 0;
}
UVALIVE 4330 Timer的更多相关文章
- C# - 计时器Timer
System.Timers.Timer 服务器计时器,允许指定在应用程序中引发事件的重复时间间隔. using System.Timers: // 在应用程序中生成定期事件 public class ...
- winform 用户控件、 动态创建添加控件、timer控件、控件联动
用户控件: 相当于自定义的一个panel 里面可以放各种其他控件,并可以在后台一下调用整个此自定义控件. 使用方法:在项目上右键.添加.用户控件,之后用户控件的编辑与普通容器控件类似.如果要在后台往窗 ...
- 【WPF】 Timer与 dispatcherTimer 在wpf中你应该用哪个?
源:Roboby 1.timer或重复生成timer事件,dispatchertimer是集成到队列中的一个时钟.2.dispatchertimer更适合在wpf中访问UI线程上的元素 3.Dispa ...
- STM32F10xxx 之 System tick Timer(SYSTICK Timer)
背景 研究STM32F10xxx定时器的时候,无意间看到了System tick Timer,于是比较深入的了解下,在此做个记录. 正文 System tick Timer是Cotex-M内核的24位 ...
- 本地数据Store。Cookie,Session,Cache的理解。Timer类主要用于定时性、周期性任务 的触发。刷新Store,Panel
本地数据Store var monthStore = Ext.create('Ext.data.Store', { storeId : 'monthStore', autoLoad : false, ...
- WinForm用户控件、动态创建添加控件、timer控件--2016年12月12日
好文要顶 关注我 收藏该文 徐淳 关注 - 1 粉丝 - 3 0 0 用户控件: 通过布局将多个控件整合为一个控件,根据自己的需要进行修改,可对用户控件内的所有控件及控件属性进行修 ...
- java Timer 定时每天凌晨1点执行任务
import java.util.TimerTask;/** * 执行内容 * @author admin_Hzw * */public class Task extends TimerTask { ...
- [C#].NET中几种Timer的使用
这篇博客将梳理一下.NET中4个Timer类,及其用法. 1. System.Threading.Timer public Timer(TimerCallback callback, object s ...
- 使用系统自带的GCD的timer倒计时模板语句遇到的小坑。。
今天折腾了下系统gcd的 但是如果不调用这句dispatch_source_cancel()那么这个timer根本不工作....解决方法如下: 实现一个倒计时用自带的gcd如此简洁.. 原因可能是如果 ...
随机推荐
- 第十二篇 Python函数之全局变量&局部变量&递归函数
全局变量:在定义的时候,顶头写的,没有任何缩进的变量就是全局变量. 全局变量的特点:在当前文件里的任何地方都可以进行调用 局部变量:在子程序里定义的变量,就是局部变量. 子程序:比如.py文件里,写的 ...
- 牛客网暑期ACM多校训练营(第七场):J-Sudoku Subrectangles
链接:J-Sudoku Subrectangles 题意:给出 n * m 的字母矩阵,公52种字母.求出不含重复元素的子矩阵的个数. 题解: L[i][j]:s[i][j] ~ s[i][ j - ...
- 数据挖掘算法:DBSCAN算法的C++实现
(期末考试快到了,所以比较粗糙,请各位读者理解..) 一. 概念 DBSCAN是一种产生划分聚类的基于密度的聚类算法,簇的个数由算法自动地确定.低密度区域中的点被视为噪声而忽略,因此DBSCAN ...
- 解决:Unable to execute dex: GC overhead limit exceeded
转自http://blog.sina.com.cn/s/blog_6e334dc70101hnug.html Android打包时下面的错误: Unable to execute dex: GC ov ...
- WebStorm中配置ExtJS
原文链接:http://zhidao.baidu.com/link?url=yX0wDWrL-b2P8k3JNNI38Fb6keuAgm0j9E-QBL1KfWXrZgLZ88grAOVJvat6dJ ...
- 【linux】linux中tree的安装
# 2018/7/29 10:17:46测试成功! 一 Tree命令简介 tree是一种递归目录列表命令,产生一个深度缩进列表文件. 二 Tree命令安装 1.下载安装包,地址:http://mama ...
- sql 先查出已知的数据或者需要的数据再筛选
sql 先查出已知的数据或者需要的数据再筛选
- Spark探索经典数据集MovieLens
Spark探索经典数据集MovieLens 阅读目录 前言 环境 初步预览 探索用户数据 探索电影数据 探索评级数据 回到顶部 前言 MovieLens数据集包含多个用户对多部电影的评级数据,也包括电 ...
- 【bzoj2631】tree LCT
题目描述 一棵n个点的树,每个点的初始权值为1.对于这棵树有q个操作,每个操作为以下四种操作之一:+ u v c:将u到v的路径上的点的权值都加上自然数c:- u1 v1 u2 v2:将树中原有的边( ...
- null?对象?异常?到底应该如何返回错误信息
这篇文章记录我的一些思考.在工作了一段时间之后. 问题的核心很简单:到底如何返回错误信息. 学生时代,见到过当时的老师的代码: if (foo() == null) { } 当然,这位老师是一位比较擅 ...