HDU 2438 Turn the corner 三分法
2014-08-13 14:19
363 查看
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1767 Accepted Submission(s): 664
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
只要 (l*sin(a)+d/cos(a)-x)/tan(a) < y 即可通过
/* 函数先增后减 找到最大值 三分 */ #include<iostream> #include<stdio.h> #include<cmath> using namespace std; #define PI acos(-1.0) double x,y,l,d; double f(double a) { return (l*sin(a)+d/cos(a)-x)/tan(a); } int main(){ double low,high,mid,mmid; while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF) { low=0;high=PI/2; if(x<d||y<d) { printf("no\n"); continue; } while(high-low>1e-7) { mid=(low+high)/2; mmid=(mid+high)/2; if(f(mid)>f(mmid)) high=mmid+1e-9; else low=mid-1e-9; } if(f(mid)<y) printf("yes\n"); else printf("no\n"); } return 0; }
相关文章推荐
- HDU 2438 Turn the corner 三分
- HDU 2438 Turn the corner(三分枚举角度)
- HDU 2438 Turn the corner
- HDU 2438 Turn the corner
- hdu 2438 Turn the corner(几何+三分)
- HDU 2438 Turn the corner (三分求极值)
- hdu 2438 Turn the corner [ 三分 ]
- hdu 2438 计算几何 三分 Turn the corner
- hdu-2438-Turn the corner(三分)
- HDU 2438 Turn the corner【三分】
- HDU 2438 Turn the corner(三分查找, 几何求解)
- hdu 2438 Turn the corner(三分)
- Turn the corner HDU - 2438 三分 枚举角度 几何
- Turn the corner HDU-2438
- HDU 2438 Turn the corner(三分查找)
- HDU 2438 Turn the corner 三分
- HDU 2438 Turn the corner (计算几何 + 三分)
- 2438 Turn the corner(数学题,三分法)
- hdu 2438 - Turn the corner(三分)
- HDU 2438 Turn the corner