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. 在Intellij里使用Erlang依赖库

    这里以protobuffs为例,记录一下环境的配置,发现这种东西中文的资料真的不多,无论是分享还是记录都是很好的 1.创建一个文件夹名use_proto, 配置rebar.config文件如下: {d ...

  2. JavaScrpit判断横竖屏

    JavaScript function setLandscapeClass(){ if(window.orientation === 90 || window.orientation === -90 ...

  3. eclipse中JPA插件的安装与使用

    说明 上周实验室学习了数据库设计相关的内容,其中涉及到将数据库实体化的问题,JPA是一个很好的实现工具,便开始着手于JPA的学习.因为JPA涉及到的知识还是挺多的,需要学习许多新的知识,所以对于JPA ...

  4. 《Effective Java(中文第二版)》【PDF】下载

    <Effective Java(中文第二版)>[PDF]下载链接: https://u253469.pipipan.com/fs/253469-230382186 Java(中文第二版)& ...

  5. SQL Server-聚焦ROW_NUMBER VS TOP N性能

    前言 抱歉各位,从八月份开始一直在着手写EntityFramework 6.x和EntityFramework Core 2.0的书籍写作,所以最近一直遗漏了对博客的管理,后面会着手于写SQL Ser ...

  6. js判断文件类型大小并给出提示

    上传文件是工作中常用的功能,不同的场景对不同的文件类型和文件大小都有不同的要求: <form id="uploadForm" method="post" ...

  7. linux系统下,安装centos7.0系统,配置网卡出现的问题(与centos5.x、centos6.x版本,有差异)

    1.新建虚拟机时,自己下载的是centos64系统,选择系统时,默认选择centos,而未选择centos64位,导致犯了一个低级错误,导致后面网卡安装一直有问题 2.查看ip命令与centos5.x ...

  8. fuser命令使用心得

    fuser命令可用于查看正使用指定file, file system, socket port的进程信息.使用-k参数可将这些进程杀掉,-i则在杀掉进程前给出提示 例子: [root@bogon ~] ...

  9. ES6/7 异步编程学习笔记

    前言 在ES6的异步函数出现之前,Js实现异步编程只有settimeout.事件监听.回调函数等几种方法 settTmeout 这种方法常用于定时器与动画的功能,因为其本质上其实是浏览器的WebAPI ...

  10. Run a task only once in (akka) cluster

    在stackOverflow网站上看到这一提问,下文是部分摘抄问题简述: Java cluster, run task only once We have a java process, which ...