zoukankan      html  css  js  c++  java
  • hdu Turn the corner

    Turn the corner

    Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 336    Accepted Submission(s): 141
     
    Problem Description
    Mr. West bought a new car! So he is travelling around the city.
    One day he comes to a vertical corner. The street he is currently in has a width x, the street he wants to turn to has a width y. The car has a length l and a width d.
    Can Mr. West go across the corner?
     
    Input
    Every line has four real numbers, x, y, l and w. Proceed to the end of file.
     
    Output
    If he can go across the corner, print "yes". Print "no" otherwise.
     
    Sample Input
    10 6 13.5 4
    10 6 14.5 4
     
    Sample Output
    yes
    no
     
     
    Source
    2008 Asia Harbin Regional Contest Online
     
    Recommend
    gaojie
     

    分析:三分+计算几何题。公式推导略,附三分最保险的写法。

    #include<cstdio>
    #include<cmath>
    #define eps 1e-6
    #define pi acos(-1)
    double x, y, L, D;
    
    double fun(double st) {
        return -x / tan(st) + L * cos(st) + D / sin(st);
    }
    
    int main() {
        double a, b, c, d, temp;
        while (scanf("%lf%lf%lf%lf", &x, &y, &L, &D) != EOF) {
            a = eps;
            b = pi / 2;
            while (b - a > eps) {
                temp = (b - a) / 3;
                c = a + temp;
                d = b - temp;
                if (fun(c) > fun(d))
                    b = d;
                else
                    a = c;
            }
            if (fun(a) <= y)
                printf("yes\n");
            else
                printf("no\n");
        }
        return 0;
    }
  • 相关阅读:
    继承中的构造函数的问题base,this的用法 Carl
    apache+php+mysql服务器环境配置注意点
    收藏音乐
    doubleClickv2as3.0 概述
    doubleClickv2as3.0 学习笔记(2)
    doubleclickv2as3.0模板
    as 2.0 笔记
    Html css 推荐文章
    [经济杂谈]如果你读懂了 股市就是取款机(要保存的) 管理帖子
    字符编码 UTF8 gb2312
  • 原文地址:https://www.cnblogs.com/baidongtan/p/2666089.html
Copyright © 2011-2022 走看看