首页 > 代码库 > hdu 2483 Turn the corner(三分)
hdu 2483 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?
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.
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 | 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(三分)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。