Description

Little frog Georgie likes to jump. Recently he have discovered the new playground that seems the perfect place to jump.

Recently the new jumping exercise has become very popular. Two vertical walls are placed on the playground, each of which has a hole.

The lower sides of the holes in the walls are on heights b1 and b2 respectively, and upper sides on heights t1 and t2. Walls are parallel and placed on distance l from each other.

The jumper starts at the distance ds from the first wall. It jumps through the first hole and lands between the walls. After that from that point he jumps through the second hole. The goal is to land exactly at the distance df from the second wall.

Let us describe the jump. The jumper starts from the specified point and starts moving in some chosen direction with the speed not exceeding some maximal speed v, determined by the strength of the jumper. The gravity of g forces him down, thus he moves along the parabolic trajectory.

The jumper can choose different starting speeds and different directions for his first and second jump.

Of course, The jumper must not attempt to pass through the wall, although it is allowed to touch it passing through the hole, this does not change the trajectory of the jump. The jumper is not allowed to pass through both holes in a single jump.

Find out, what must be the maximal starting speed of the jumper so that he could fulfil the excersise.

Input

Input file contains one or more lines, each of which contains eight real numbers, separated by spaces and/or line feeds. They designate b1, t1, b2, t2, l, ds, df and g. All numbers are in range from 10-2 to 103, t1 ≥ b1 + 10-2, t2 ≥ b2 + 10-2.

Input file contains at most 1000 test cases.

Output

      For each line of the input file output the smallest possible maximal speed the jumper must have to fulfil the exercise. If it is impossible to fulfil it, output -1. Your answer must be accurate up to 10-4.

Sample Input

0.3 1.0 0.5 0.9 1.7 1.2 2.3 9.8
0.6 0.8 0.6 0.8 2.4 0.3 1.5 0.7

Sample Output

5.2883
1.3127
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <math.h>
#include <vector>
#include <string>
#include <utility>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <functional> using namespace std;
const double pi=acos(-);
const int maxn=;
const int INF=0x3f3f3f;
const double eps=1e-;
int dcmp(double x){
if(fabs(x)<eps)return ;
if(x>)return ;
return -;
}//精度为eps的比较
double b1,t1,b2,t2,l,ds,df,g;
double calu(double dis,double x,double b,double t){
double v=;
double mid=dis/;
double a=-/dis;
double y=a*x*x+x;
if(y>=b&&y<=t){
double h=a*mid*mid+mid;
double t,vx,vy;
t=sqrt(*h/g);
vx=dis/t/;
vy=g*t;
v=vx*vx+vy*vy;
}
else{
if(y<b)
a=b/(x*x-dis*x);
else
a=t/(x*x-dis*x);
double h=a*mid*(mid-dis);
double t,vx,vy;
t=sqrt(*h/g);
vx=dis/t/;
vy=g*t;
v=vx*vx+vy*vy; }
return v;
}
double solve(double t){
double ans1=ds+t;
double ans2=df+l-t;
double v1,v2;
v1=calu(ans1,ds,b1,t1);
v2=calu(ans2,l-t,b2,t2);
return max(v1,v2);
}
int main(){
while(scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&b1,&t1,&b2,&t2,&l,&ds,&df,&g)!=EOF){
double low,high,mid,midd;
low=;
high=l;
while(high-low>eps){
mid=(high+low*)/;
midd=(low+high*)/;
if(solve(mid)<solve(midd))high=midd;
else low=mid;
}
printf("%.4f\n",sqrt(solve(mid)));
}
return ;
}

Little Jumper---(三分)的更多相关文章

  1. C - Little Jumper (三分)

    题目链接:https://cn.vjudge.net/contest/281961#problem/C 题目大意:青蛙能从一个点跳到第三个点,如图,需要跳两次.问整个过程的最大起跳速度中的最小的. 具 ...

  2. hdu3714 三分找最值

    Error Curves Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Tota ...

  3. BZOJ 1857 传送带 (三分套三分)

    在一个2维平面上有两条传送带,每一条传送带可以看成是一条线段.两条传送带分别为线段AB和线段CD.lxhgww在AB上的移动速度为P,在CD上的移动速度为Q,在平面上的移动速度R.现在lxhgww想从 ...

  4. hdu 4717(三分求极值)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4717 思路:三分时间求极小值. #include <iostream> #include ...

  5. HDU2438 数学+三分

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  6. 三分之一的程序猿之社交类app踩过的那些坑

    三分之一的程序猿之社交类app踩过的那些坑 万众创新,全民创业.哪怕去年陌生人社交不管融资与否都倒闭了不知道多少家,但是依然有很多陌生人社交应用层出不穷的冒出来.各种脑洞大开,让人拍案叫起. 下面我们 ...

  7. 基于jPlayer的三分屏制作

    三分屏,这里的三分屏只是在一个播放器里同时播放三个视频,但是要求只有一个控制面板同时控制它们,要求它们共享一个时间轨道.这次只是简单的模拟了一下功能,并没有深入的研究. 首先,需要下载jPlayer, ...

  8. 【BZOJ-1857】传送带 三分套三分

    1857: [Scoi2010]传送带 Time Limit: 1 Sec  Memory Limit: 64 MBSubmit: 1077  Solved: 575[Submit][Status][ ...

  9. ACM : HDU 2899 Strange fuction 解题报告 -二分、三分

    Strange fuction Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  10. bzoj1857: [Scoi2010]传送带--三分套三分

    三分套三分模板 貌似只要是单峰函数就可以用三分求解 #include<stdio.h> #include<string.h> #include<algorithm> ...

随机推荐

  1. Why restTemplate.put() throws “HttpClientErrorException: 404 Not Found”

      I make a put request RestTemplate restTemplate = new RestTemplate(); restTemplate.put(new URI(&quo ...

  2. SAP ECC PP 配置文档

    SAP ECC 6.0 Configuration Document Production Planning & Control (PP) 1. General Settings 1.1 Ma ...

  3. 初探Stage3D(一) 3D渲染基础原理

    关于本文 本文主要想介绍一下3D渲染的基本流程,及怎样把一个三角形(0,1,0),(1,0,1),(0,0,1)最终渲染到屏幕上来.文章的目的是对3D渲染流程做一个简单的介绍,其中不涉及任何语言的AP ...

  4. 强(strong)、软(soft)、弱(weak)、虚(phantom)引用

    https://github.com/Androooid/treasure/blob/master/source/lightsky/posts/mat_usage.md 1.1 GC Root JAV ...

  5. android手势创建及识别

    使用一些浏览器或者输入法应用时会有一些手势操作,还可以自定义手势.这些神奇的操作是怎么做的呢?这一篇重点记录手势的识别和创建.这篇的内容使用到的是android.gesture包,具体的例子参考的是S ...

  6. zk框架销毁Page上的Component

    销毁Page上的Component ZK的组件之间是树状结构的,每一组件都只有一个根. 从页面上销毁一个组件可以通过下面两种方式来实现: 1. 组件不是根组件时:Component.setParent ...

  7. Django Push HTTP Response to users

    Django Push HTTP Response to users I currently have a very simple web application written in Django, ...

  8. Access导出csv 内容添加双引号 vba

    要求:导出的csv文件,用文本工具打开时,文字内容需要有双引号,如下:"1","name1","name2","" 我之 ...

  9. ruby -- 基础学习(七)时间的内置函数和格式说明

        Rails -- 时间的内置函数和格式说明 FROM:http://www.douban.com/note/99064603/ time = Time.now #获得当前时间 time.gmt ...

  10. Axure RP介绍

    1.什么是原型设计?产品原型设计(Prototype Design)最基础的工作,就是结合批注.大量的说明以及流程图画框架图WireFrame,将自己的产品原型完整而准确的表述给 UI.UE.程序工程 ...