Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 3952 Accepted Submission(s): 1658
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 | We have carefully selected several similar problems for you: 2441 2442 2443 2440 2439
题目大意:有一个带拐角的街道,水平宽度为x,竖直宽度为y 有一辆长为l宽为w的小汽车从水平街道驶来,问你它能否进入竖直街道
思路:以汽车的上端边所在直线进行分析,,将右下角那个点为坐标原点建立直角坐标系 求得直线Y=tan@*x+L*sin@+D/cos@;此时Y=X,求解x,再判断x与-y的关系,三分@,(@表示角,这里三分的是角,不是边或其他)
图为:
代码:
/*
题意:有一个带拐角的街道,水平宽度为x,竖直宽度为y
有一辆长为l宽为w的小汽车从水平街道驶来,问你它能否进入竖直街道
思路:以汽车的上端边所在直线进行分析,,将右下角那个点为坐标原点建立直角坐标系
求得直线Y=tan@*x+L*sin@+D/cos@;此时Y=X,求解x,再判断x与-y的关系,三分@
*/
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
#define eps 1e-7
#define ll long long
#define inf 0x3f3f3f3f
#define bug printf("mmp\n");
#define ul unsigned long long
#define mm(a,b) memset(a,b,sizeof(a))
#define T()int test,q=1,tt;scanf("%d",&test),tt=test;while(test--)
const int N=1e2+10;
const int maxn=1e6+100;
const int mod=1000000007;
const double pi=acos(-1.0);
double x,y,l,w;
double finds(double du)
{
return (-x+l*sin(du)+w/cos(du))/tan(du);
}
double three_search(double low ,double high)
{
double mid=0,mids=0;
while(high-low>eps)
{
mid=(low+high)*0.5;
mids=(mid+high)*0.5;
if(finds(mid)>finds(mids))
high=mids;
else
low=mid;
}
return finds(mid);
}
int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF)
{
if(x<w||y<w)
{
printf("no\n");
continue;
}
if(three_search(0,pi/2.0)<=y)
printf("yes\n");
else
printf("no\n");
}
return 0;
}