UESTC 2014 summer training #11 div.2

Source: Internet
Author: User

E-prototype, zoj 3235

After (D2, 0) is substituted into the second equation, an equation is obtained: the equation of the starting point of the parabolic passing through (D2, 0 ).

Then we can combine it with the first equation to solve the intersection of the two parabolic curves, and then check whether it is between 0 and ~ In the D2 range, Will building2 be hit when x = D1?

Note that it may be possible to reach (D2, 0) without sliding. Handle this situation first.

 

At first, I was dumb to understand the incorrect question meaning. Later, I fixed the problem and thought about it again. For example, a = 0 and Delta <0. Finally, I found that I forgot to play SQRT !!!

 

It was a little difficult to answer questions in this competition. At that time, I was quite flustered. I was afraid that I could not answer questions, and I had no depth of thinking. I got down to several questions.

#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;}

 

UESTC 2014 summer training #11 div.2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.