Turn the corner |
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
Total Submission(s): 654 Accepted Submission(s): 291 |
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
|
/* x和y值和题目相反,搞了了好几遍 */ #include<bits/stdc++.h> #define exp 1e-9 #define pi acos(-1) using namespace std; /* 小车不靠墙壁段的直线方程 */ double dis(double Q,double l,double d,double x) { double b=d/cos(Q)+l*sin(Q); return (b-x)/tan(Q); } int main() { //freopen("C:\\Users\\acer\\Desktop\\in.txt","r",stdin); double x,y,l,d; while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF) { double left=0,right=pi/2,mid,midmid; //cout<<right<<endl; while(right-left>exp) { mid=left+(right-left)/3; midmid=right-(right-left)/3; //假设求解最大极值. if(dis(mid,l,d,x)>=dis(midmid,l,d,x)) right=midmid; else left=mid; } //cout<<"mid="<<mid<<endl; //cout<<(int)dis(mid,l,d,x)<<endl; if(dis(mid,l,d,x)<y) puts("yes"); else puts("no"); } return 0; }