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;
}










