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