# Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 3196    Accepted Submission(s): 1302

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

给出街道在x轴的宽度X，y轴的宽度Y，还有车的长l和宽w，判断是否能够转弯成功。

盗网上大牛一张图，画的很详细

尽可能让车贴着外面的墙璧转弯，也就是图中的x轴和y轴，此时红线的方程就是图中的方程，此时p点的位置就是让y=X时解得的x值，要保证p点在Y内，也就是-x<y,假若在转弯的所有角度中都满足这个条件，那么就能转弯，分析得，-x先增大后减小，所以用三分求最大-x值。

``` 1 #include <bits/stdc++.h>
2 using namespace std;
3 double x,y,l,w;
4 const double eps=1e-6;
5 const double pi=acos(-1.0);
6 double solve(double angle)
7 {
8     return (-x+l*sin(angle)+w/cos(angle))/tan(angle);
9 }
10 int main()
11 {
12     while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF)
13     {
14         double ll=0,rr=pi/2,midx,midy;
15         while(rr-ll>eps)
16         {
17             midx=(ll+ll+rr)/3;
18             midy=(ll+rr+rr)/3;
19             if(solve(midx)>solve(midy))
20             rr=midy;
21             else ll=midx;
22         }
23         if(solve(ll)<y)
24             printf("yes\n");
25         else printf("no\n");
26     }
27     return 0;
28 }```

783 篇文章62 人订阅

0 条评论

## 相关文章

### SDP（2）：ScalikeJDBC-Connection Pool Configuration

scalikeJDBC可以通过配置文件来设置连接池及全局系统参数。对配置文件的解析是通过TypesafeConfig工具库实现的。默认加载classpath...

3474

3013

2635

3507

### PAT Advanced 1042

Shuffling is a procedure used to randomize a deck of playing cards. Because sta...

811

### 3891: [Usaco2014 Dec]Piggy Back

3891: [Usaco2014 Dec]Piggy Back Time Limit: 10 Sec  Memory Limit: 128 MB Submit:...

3719

3114

1233

4019

2669