Little Jumper---(三分)

Posted 茶飘香~

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Little Jumper---(三分)相关的知识,希望对你有一定的参考价值。

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(-1);
const int maxn=100005;
const int INF=0x3f3f3f;
const double eps=1e-12;
int dcmp(double x){
    if(fabs(x)<eps)return 0;
    if(x>0)return 1;
    return -1;
}//精度为eps的比较
double b1,t1,b2,t2,l,ds,df,g;
double calu(double dis,double x,double b,double t){
    double v=0;
    double mid=dis/2;
    double a=-1/dis;
    double y=a*x*x+x;
    if(y>=b&&y<=t){
        double h=a*mid*mid+mid;
        double t,vx,vy;
        t=sqrt(2*h/g);
        vx=dis/t/2;
        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(2*h/g);
        vx=dis/t/2;
        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=0;
        high=l;
        while(high-low>eps){
            mid=(high+low*2)/3;
            midd=(low+high*2)/3;
            if(solve(mid)<solve(midd))high=midd;
            else low=mid;
        }
        printf("%.4f\n",sqrt(solve(mid)));
    }
    return 0;
}

 

以上是关于Little Jumper---(三分)的主要内容,如果未能解决你的问题,请参考以下文章

分享一个shell脚本:通过Jumper机器来创建Jumper和target机器账号

Jumper_Waf2.0——可视化界面

如何从codeigniter中的url获取#jumper部分? [复制]

比赛作品已经提交了,今晚我竟然失眠了—Jumper蹦跶的人

sh 安装z jumper.sh

在篮球中jumper / drive / post up等是啥意思?