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
 
题目大意:
 
给出街道在x轴的宽度X,y轴的宽度Y,还有车的长l和宽w,判断是否能够转弯成功。
 
题解:
 
如图:

可以很容易地观察到上面这样一条不等式:
而这个不等式可以很容易地观察出三分性质。
所以求解就很easy了。
 
代码如下:
 
#include<cstdio>
#include<cmath>
#include<iostream>
#define PI 3.14159
using namespace std; double x,y,l,d; double pd(double a)
{
return sin(a)*l+d/cos(a)-y*tan(a);
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
double lm,rm,le=0.0,r=PI/;
while(fabs(r-le)>1e-)
{
lm=(le*2.0+r)/3.0;
rm=(le+r*2.0)/3.0;
if(pd(lm)>pd(rm)) r=rm;
else le=lm;
}
if(pd(le)<=y)
printf("yes\n");
else
printf("no\n");
}
}

最新文章

  1. 移植milo的全局光照渲染器代码
  2. JavaScript强化教程——jQuery UI API 类别
  3. linux crontab命令参数及用法详解--linux自动化定时任务cron
  4. elixir 高可用系列(五) Supervisor
  5. 解决VS2010中产生的ipch文件夹和sdf文件
  6. RMAN数据库恢复之控制文件和参数文件恢复
  7. 照片详细解释YUV420数据格式
  8. 九度oj题目&amp;amp;吉大考研11年机试题全解
  9. echarts样式修改
  10. python demo整理
  11. PHP的高并发和大数据处理
  12. MVC和MTV模式
  13. 与音频相关的技术知识点总结(Linux方向的开发)
  14. 学习HTML+JSP(更新中)
  15. 织梦会员 Warning: preg_replace(): The /e modifier is no longer supported, us...
  16. 洛谷.2754.星际转移问题(最大流Dinic 分层)
  17. Android requires compiler compliance level 5.0 or 6.0. Found &#39;1.4&#39; instead.解决方法
  18. 前端架构之路:Windows下安装Nodejs步骤
  19. Excel 公式集
  20. SVG系列教程:SVG简介与嵌入HTML页面的方式

热门文章

  1. dojo处理删除操作报错
  2. Java集合源代码剖析(二)【HashMap、Hashtable】
  3. Django的Models
  4. HBase:Shell
  5. 通信机制-TCP/IP、Http、Socket的区别
  6. [array] leetcode - 42. Trapping Rain Water - Hard
  7. [数据结构]C语言栈的实现
  8. touchstart和touchend事件
  9. gitlab 接入 openldap、AD
  10. java环境配置教程jde,jre