码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 2483 Turn the corner(三分)

时间:2014-11-24 22:39:25      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:hdu2438   三分   turn the corner   

Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1899    Accepted Submission(s): 719


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?
bubuko.com,布布扣
 

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
 

Recommend
gaojie   |   We have carefully selected several similar problems for you:  2444 2441 2442 2443 2440 
 


CODE:
#include<stdio.h>
#include<math.h>
double l,d,x,y;
double ff(double n)
{
    double x0,y0,c,s;
    s=sin(n);
    c=cos(n);
    x0=-1*(d/s+c*l);
    y0=(d/c+s*l);
    double tmp=(1.0-x/y0)*x0*(-1);
    return tmp;
}

int main()
{
    double left,right,mid1,mid2,max;
    while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
        {
            left=0;
            right=asin(1.0);
            max=0;
            while(fabs(right-left)>=0.000001)
                {
                    mid1=(right+left)/2;
                    mid2=(left+mid1)/2;
                    if(ff(mid1)>ff(mid2))
                        {
                            left=mid2;
                        }
                    else
                        {
                            right=mid1;
                        }
                }
            double tmp=ff(left);
            if(tmp<y)printf("yes\n");
            else printf("no\n");
        }
    return 0;
}


hdu 2483 Turn the corner(三分)

标签:hdu2438   三分   turn the corner   

原文地址:http://blog.csdn.net/acm_baihuzi/article/details/41451471

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!