HDU 2438 Turn The corner (calculate geometry + three points)

Source: Internet
Author: User


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)

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.