HDU 2348 Turn The corner (three points && geometry) (medium)

Source: Internet
Author: User

Turn the CornerTime limit:3000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 2229 Accepted Submission (s): 856


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



Test instructions

It is known that the length and width of the car, L and W, and the width of the two roads are X and Y, the car's road width is x, asking if the car can turn smoothly?

Analysis: Whether the car can smooth turn depends on the limit of the situation, with the change in angle, the car from the opposite side of the road is greater than or equal to 0

In



In the need to calculate whether the maximum value of H is less than or equal to Y during a turnobviously, with the increase of the angle θ, the maximum height of H first increases and then decreases, that is, the convex function, you can use the three-part method to solve

Code:

#include <iostream> #include <algorithm> #include <math.h> #include <cstdio>using namespace std ; #define PI 3.141592653double x,y,l,w;double cal (double A) {    double S=l*cos (a) +w*sin (a)-X;    Double H=s*tan (a) +w*cos (a);    return h;} int main () {    while (scanf ("%lf%lf%lf%lf", &x,&y,&l,&w)!=eof)    {        double left=0.0,right=pi /2;        Double lm,rm;        while (Fabs (right-left) >1e-6)        {            lm= (left*2.0+right)/3.0;            Rm= (left+right*2.0)/3.0;            if (Cal (LM) >cal (RM))                right=rm;            else left=lm;        }        if (Cal (left) <=y)            printf ("yes\n");        else printf ("no\n");    }    return 0;}

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

HDU 2348 Turn The corner (three points && geometry) (medium)

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.