Problem D. Delay Time Input file: standard input Output file: standard output Time limit: 1 second Memory limit: 512 megabytes Petr and Egor are measuring the gravitational acceleration g on their physics lessons using a special device. An electromagnetic trap holding a metal ball is installed on an arbitrary positive height chosen by the user. As soon as the button is pressed, the timer starts, the electromagnet turns off and the released ball falls on a table. The timer stops immediately when the ball touches the table. h Petr has set the height to h1 meters and got t1 seconds on the timer as a result of the experiment. In his turn Egor changed the height to h2 meters and got t2 seconds shown on the timer. While calculating the value of g they surprisingly got significantly different results, and asked a teacher to clarify the nature of this inconsistency. As it often happens with this sort of “mystery”, the solution was simple: there was a constant delay of d seconds between the start of the timer and the moment the ball actually starts to fall, caused by the time needed for the electromagnet to lose its grip on the ball. They quickly managed to determine this value from the given information and calculate the correct g. Can you manage to do this in five hours? Assume that the gravitational acceleration and the delay time are the same in both experiments. Air friction and other effects are considered negligible for the purpose of this experiment. When the ball with zero initial speed starts to fall affected only by the gravitational acceleration g, the distance it travels in t seconds is given by a well-known formula: ρ(t) = g · t 2 2 Input The first line of the input contains real values h1 and t1 — the height selected by Petr, in meters, and the time value he has measured, in seconds (0 < h1, t1 ≤ 10). The second line contains real values h2 and t2 — the values of height in meters and time in seconds for Egor’s experiment (0 < h2, t2 ≤ 10, h1 ̸= h2). All values in the input are given with no more than three digits after the decimal point. Page 5 of 17 ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 It is guaranteed that input data is consistent, that means that positive real g and d were used to generate the input. Output Output the value of electromagnet delay d in seconds. Your answer will be considered correct if its absolute or relative error doesn’t exceed 10−4 . Formally, if your answer is a and the jury’s answer is b, the checker will accept your answer if |a−b| max(1,b) ≤ 10−4 . Examples standard input standard output 1.495 2.009 7.674 2.708 1.456709 5 1.25 1.25 0.75 0.250000 Note In the first sample the gravitational acceleration g is approximately equal to 9.80246, while in the second sample it is 10. Note that g in the testset can vary arbitrarily and is not guaranteed to be related to the gravitational acceleration on the surface of any known planet.

题意:给出球的两次坠落高度,开始下落时间和球坠地的时间分别是H1,T1,H2,T2,但是测量有误差,求误差大小。

分析:暴力枚举误差。

 /**
Create By yzx - stupidboy
*/
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef double DB;
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair inline int Getint()
{
int Ret = ;
char Ch = ' ';
bool Flag = ;
while(!(Ch >= '' && Ch <= ''))
{
if(Ch == '-') Flag ^= ;
Ch = getchar();
}
while(Ch >= '' && Ch <= '')
{
Ret = Ret * + Ch - '';
Ch = getchar();
}
return Flag ? -Ret : Ret;
} const DB EPS = 1e-;
DB h1, h2, t1, t2; inline void Input()
{
cin >> h1 >> t1 >> h2 >> t2;
} inline DB Sqr(DB x)
{
return x * x;
} inline DB Work(DB x)
{
DB g1 = 2.0 * h1 / Sqr(t1 - x);
DB g2 = 2.0 * h2 / Sqr(t2 - x);
return abs(g1 - g2);
} inline void Solve()
{
DB ret = 0.0, cnt = 1.0 * INF;
for(DB delay = 0.0; delay <= min(t1, t2) - EPS; delay += EPS)
{
DB delta = Work(delay);
if(cnt > delta)
cnt = delta, ret = delay;
}
printf("%.6lf\n", ret);
} int main()
{
//freopen("D.in", "r", stdin);
Input();
Solve();
return ;
}

ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 D. Delay Time的更多相关文章

  1. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 G. Garden Gathering

    Problem G. Garden Gathering Input file: standard input Output file: standard output Time limit: 3 se ...

  2. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 I. Illegal or Not?

    I. Illegal or Not? time limit per test 1 second memory limit per test 512 megabytes input standard i ...

  3. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 K. King’s Rout

    K. King's Rout time limit per test 4 seconds memory limit per test 512 megabytes input standard inpu ...

  4. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 H. Hashing

    H. Hashing time limit per test 1 second memory limit per test 512 megabytes input standard input out ...

  5. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 C. Colder-Hotter

    C. Colder-Hotter time limit per test 1 second memory limit per test 512 megabytes input standard inp ...

  6. ACM ICPC 2015 Moscow Subregional Russia, Moscow, Dolgoprudny, October, 18, 2015 A. Anagrams

    A. Anagrams time limit per test 1 second memory limit per test 512 megabytes input standard input ou ...

  7. hdu 5444 Elven Postman(二叉树)——2015 ACM/ICPC Asia Regional Changchun Online

    Problem Description Elves are very peculiar creatures. As we all know, they can live for a very long ...

  8. 2015 ACM / ICPC 亚洲区域赛总结(长春站&北京站)

    队名:Unlimited Code Works(无尽编码)  队员:Wu.Wang.Zhou 先说一下队伍:Wu是大三学长:Wang高中noip省一:我最渣,去年来大学开始学的a+b,参加今年区域赛之 ...

  9. Moscow Subregional 2013. 部分题题解 (6/12)

    Moscow Subregional 2013. 比赛连接 http://opentrains.snarknews.info/~ejudge/team.cgi?contest_id=006570 总叙 ...

随机推荐

  1. 营业额统计(bzoj1588)

    Description 营业额统计 Tiger最近被公司升任为营业部经理,他上任后接受公司交给的第一项任务便是统计并分析公司成立以来的营业情况. Tiger拿出了公司的账本,账本上记录了公司成立以来每 ...

  2. Roadblocks(poj 3255)

    题意:给出n个点,m条双向边,求严格次短路. /* 先spfa预处理出起点到每个点的和每个点到终点的最短距离,然后枚举每条边(这条边必须走),计算此时的最短路径,得出严格次短路. 正确性:因为对于一条 ...

  3. python基础——装饰器

    python基础——装饰器 由于函数也是一个对象,而且函数对象可以被赋值给变量,所以,通过变量也能调用该函数. >>> def now(): ... print('2015-3-25 ...

  4. 三、jQuery--jQuery基础--jQuery基础课程--第9章 jQuery 常用插件

    1.表单验证插件——validate 该插件自带包含必填.数字.URL在内容的验证规则,即时显示异常信息,此外,还允许自定义验证规则,插件调用方法如下:$(form).validate({option ...

  5. CLR via C#(12)-委托Delegate

    本来按照进度应该学习事件了,可总觉得应该委托在前,事件在后,才好理解. 委托是一个类,它提供了回调函数机制,而且是类型安全的.使用委托可以将方法当作另一个方法的参数来进行传递,这种将方法动态地赋给参数 ...

  6. 数据结构和算法 – 10.集合

    集合: 联合.交叉.差异.子集 using System; using System.Collections; using System.Collections.Generic; using Syst ...

  7. C#回顾 - 2.NET的IO:Path、File、FileInfo、Directory、DirectoryInfo、DriveInfo、FileSystemWatcher

        1.管理文件系统 一般而言,应用程序都会有保存数据.检索数据的需求. 1.1 使用 path 类来访问文件路径 [path常用的方法]:http://www.cnblogs.com/tangg ...

  8. 【转载】Python编写简易木马程序

    转载来自: http://drops.wooyun.org/papers/4751?utm_source=tuicool 使用Python编写一个具有键盘记录.截屏以及通信功能的简易木马. 首先准备好 ...

  9. 攻城狮在路上(壹) Hibernate(一)--- 软件环境、参考书目等一览表

    1.环境配置: web容器:tomcat6.0 JDK:1.7.0_51 hibernate:4.2.0.Final 操作系统:WIN8 64位 数据库:mysql  Ver 14.12 Distri ...

  10. android 相对布局里面的一些属性

    一.   有关于RelativeLayout布局的一些属性 1.  相对于兄弟控件的位置:android:layout_below Android:layout_toLeftof Android:la ...