
10 6 13.5 4 10 6 14.5 4
yes no
#include <cstdio>
#include <cmath>
double const PI = acos(-1.0);
double 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 (计算几何 + 三分)
原文地址:http://blog.csdn.net/tc_to_top/article/details/44523271