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

【三分法】hdu2438 Turn the corner的更多相关文章

  1. HDU2438 Turn the corner【三分法】【数学几何】

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  2. HDU2438:Turn the corner(三分)

    传送门 分析 根据这张图,我们只要使得h<=y即可,可以发现h是一个凸函数,故使用三分,具体见代码 代码 #include<cstdio> #include<cstring&g ...

  3. Turn the corner (三分)

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  4. hdu 2348 Turn the corner(三分&amp;&amp;几何)(中等)

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  5. Turn the corner

    Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...

  6. Turn the corner

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  7. HDU 2438 Turn the corner(三分查找)

    托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! ...

  8. hdu 2438 Turn the corner [ 三分 ]

    传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  9. hdu 2438 Turn the corner(几何+三分)

    Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...

随机推荐

  1. .NET Core 已经实现了PHP JIT,现在PHP是.NET上的一门开发语言

    12月23日,由开源中国联合中国电子技术标准化研究院主办的2017源创会年终盛典在北京万豪酒店顺利举行.在本次大会上,链家集团技术副总裁.PHP 开发组核心成员鸟哥发表了以 " PHP Ne ...

  2. java反射(转)

    作者:奋斗的小子链接:https://www.zhihu.com/question/24304289/answer/38218810来源:知乎著作权归作者所有,转载请联系作者获得授权. 反射之中包含了 ...

  3. c#值类型与引用类型区别

    值类型对象的两种表示方式:未装箱和已装箱,引用类型总是处于已装箱 值类型从System.ValueType派生.该类型提供了与System.Object相同方法,但System.ValueType重写 ...

  4. 【正则表达式】匹配时间格式:hh:mm或h:m

    ^(0?[0-9]|1[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9])$

  5. HTTP服务及状态码

    第一章 HTTP 1.1 HTTP协议的概念 HTTP协议,全称HyperText Transfer Protocol,中文名为超文本传输协议,是互联网上常用的通信协议之一,它有很多的应用.但是流行的 ...

  6. XE10 clientDataset 访问 DataSnap 服务端报错问题,锲而不舍找方法,终于解决了

    1. 开发环境说明:win 10 下安装了XE10.2和Delphi7 2.按照网上datasnap 三层与使用xe10 自带的samples 的例子,访问数据库都要报莫名的地址错误,这个太不人性化: ...

  7. Memcached的简介和使用

    缘起: 在数据驱动的web开发中,经常要重复从数据库中取出相同的数据,这种重复极大的增加了数据库负载.缓存是解决这个问题的好办法.但是ASP.NET中的虽然已经可以实现对页面局部进行缓存,但还是不够灵 ...

  8. bzoj 4446: [Scoi2015]小凸玩密室

    Description 小凸和小方相约玩密室逃脱,这个密室是一棵有n个节点的完全二叉树,每个节点有一个灯泡.点亮所有灯 泡即可逃出密室.每个灯泡有个权值Ai,每条边也有个权值bi.点亮第1个灯泡不需要 ...

  9. Docker(十二):Docker集群管理之Compose

    1.Compose安装 curl -L https://github.com/docker/compose/releases/download/1.1.0/docker-compose-`uname ...

  10. lesson - 6 Linux下磁盘管理

    1. 查看磁盘或者目录的容量df  查看磁盘各分区使用情况   不加参数以k为单位   df -i inode数,df -h  以G或者T或者M   df -m  以M单位显示  du 查看目录或者文 ...