Turn the corner
Time limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total Submission (s): 2059 Accepted Submission (s): 785
problem DescriptionMr West bought a new car! So he's travelling around the city.
One day he comes to a vertical corner. The street he is currently in have a width x, the street he wants to turn to have a width y. The car has a length l and a width d.
Can Mr West go across the corner?
InputEvery line have four real numbers, X, Y, L and W.
Proceed to the end of file.
OutputIf He can go across the corner, print "Yes". Print "No" otherwise.
Sample Input
10 6 13.5 410 6 14.5 4
Sample Output
Yesno
Source Asia Harbin Regional Contest Online
Title Link: http://acm.hdu.edu.cn/showproblem.php?pid=2438
The main topic: is to give 4 parameters, ask the car can turn the corner
Topic Analysis: Push formula, use the angle to indicate the distance from the point perpendicular to the corner of the curve when turning, it is obvious that H is the function of convexity, the three-point angle, the maximum value, if the maximum value is less than Y can pass, h = (l * cos (a) + W * sin (a)-X) * (Tan (a) + W * COS (a))
#include <cstdio> #include <cmath>double const PI = ACOs ( -1.0);d ouble Const EPS = 1e-7;double x, y, L, W, S, h; Double cal (Double a) { s = l * cos (a) + W * sin (a)-X; return S * TAN (a) + w * cos (a); int main () { double Le, RI, mid1, Mid2; while (scanf ("%lf%lf%lf%lf", &x, &y, &l, &w)! = EOF) { le = 0.0; RI = PI/2; while (Fabs (ri-le) > EPS) { Mid1 = (le + ri)/2; Mid2 = (Mid1 + ri)/2; if (Cal (MID1) >= cal (MID2)) ri = Mid2; else le = mid1; } if (Cal (MID1) <= y) printf ("yes\n"); else printf ("no\n");} }
HDU 2438 Turn The corner (calculate geometry + three points)