• UESTC 2014 Summer Training #11 Div.2


    E - Prototype  ZOJ 3235

      把(d2,0)代入第二个方程可以得到一个方程:经过(d2,0)的抛物线的起点的方程

      再把它和第一个方程联立,就能解出两条抛物线的交点,再验算:是否在0~d2范围内,是否在x=d1时会撞到building2

      注意可能不需要滑行就能到达(d2,0),先特殊处理这种情况

      一开始傻逼理解错题意,后来一直修改又去考虑了不会出现的情况,例如A=0,delta<0,最后才发现了我忘记打sqrt了!!!

      这场比赛题略难...就不会做  当时还是比较慌,很怕过不了题,加上自己思考的没有深度...E题挂了好几发

    #include <iostream>
    #include <cstdio>
    #include <cstdlib>
    #include <cstring>
    #include <cmath>
    
    using namespace std;
    
    const double eps = 1e-10;
    
    double h1, h2, d1, d2, a, b;
    
    bool check(double x)
    {
        double y = b*(d2-x)*(d2-x);
        if(x < 0 || x > d2)    return false;
        if(x > d1 && h1-a*d1*d1 > h2-eps)
            return true;
        else if(y-b*(d1-x)*(d1-x) > h2-eps)
            return true;
        return false;
    }
    
    int main()
    {
    #ifdef LOCAL
        freopen("E.in", "r", stdin);
    #endif
        while(cin >> h1 >> h2 >> d1 >> d2 >> a >> b) {
    //do not glide
            if(abs(h1-a*d2*d2) < eps && h1-a*d1*d1 > h2-eps) {
                cout << "Yes" << endl;
                continue;
            }
    //glide once
            double A, B, C, delta;
            A = (b+a);
            B = -2*b*d2;
            C = b*d2*d2-h1;
            delta = B*B-4*A*C;
            if(delta < 0) {
                cout << "No" << endl;
                continue;
            }
            double x1 = ((-B)+sqrt(delta))/(2*A), x2 = ((-B-sqrt(delta)))/2/A;
            if(check(x1) || check(x2)) {
                cout << "Yes" << endl;
                continue;    
            }
            cout << "No" << endl;
        }
        return 0;
    }
  • 相关阅读:
    学习python第六天
    学习python第五天
    学习python第四天
    学习python第二天
    网工学Python——模块和包
    网工学Python——初识函数
    网工学Python——常用模块
    网工学Python——基础知识
    网工学Python——目录
    Python-面向对象
  • 原文地址:https://www.cnblogs.com/gemmeg/p/3871033.html
Copyright © 2020-2023  润新知