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?
Proceed to the end of file.
#include
#include
#define pi 3.141592653589793238
using namespace std;
double x,y,l,d;
double cal(double s)//进行三分的条件
{
return l*cos(s)+(d-x*cos(s))/(sin(s));
//l*cos(s)+(d-x*cos(s))/(sin(s))就是过弯过程中在y方向上的宽
}
{
//freopen("in.txt", "r", stdin);
double left,right,mid,midmid;
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
//printf("x=%.1f y=%.1f l=%.1f d=%.1f\n",x,y,l,d);
if(d>x||d>y)
{
printf("no\n");
continue;
}
left=0;
right=pi/2;//最大只能是pi/2,不可能倒着转弯吧
//printf("left=%.1f right=%.1f\n",left,right);
while (right-left>1e-10)
{
mid=(left+right)/2;
midmid=(mid+right)/2;
//printf("mid=%.4f mid mid=%.4f\n",mid,midmid);
if (cal(mid)>=cal(midmid))//过弯过程中在y方向上的宽,与y比较
right=midmid;
else left=mid;
}
//printf("right=%.1f\n",right);
if(cal(right)>y)//如果最大角度过弯时还是比y宽就肯定过不去
printf("no\n");
else
printf("yes\n");
}
return 0;
}