Turn the corner


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

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

题目大意:有一个直角拐角,给你水平道路宽度Y和竖直高度X,再给你汽车的长l,宽w

问:汽车能否通过这个拐角。

思路:假设汽车的宽度大于水平道路宽度Y或是竖直高度X。不管怎样都通只是。接下来

考虑普通情况。

如图:若汽车最左边与墙一直靠紧,则仅仅须要推断右边最高点是否超过了Y。

设θ为汽车与水平方向的夹角,s为汽车最右边的角到拐点的水平距离。那么

s = l*cos(θ) + w*sin(θ)
- x,从而得出 h = s*tan(θ)+w*cos(θ)。

θ角从0~π/2,变化,h则从低到高再究竟,且是一个凸形函数。利用三分方法

得到最高点的h。与Y比較推断能否通过。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
const double PI = acos(-1.0);
double x,y,l,w;
double calc(double angle)
{
double s = l*cos(angle) + w*sin(angle) - x;
double h = s*tan(angle) + w*cos(angle);
return h;
}
int main()
{ while(cin >> x >> y >> l >> w)
{
double left,right,mid,midmid;
left = 0;
right = PI/2;
while(right-left >= 1e-7)
{
mid = (left+right)/2;
midmid = (mid+right)/2;
if(calc(mid) > calc(midmid))
right = midmid;
else
left = mid;
}
if(x<w || y<w || calc(mid) > y)
cout << "no" << endl;
else
cout << "yes" << endl;
} return 0;
}

HDU2438 Turn the corner【三分法】【数学几何】的更多相关文章

  1. 【三分法】hdu2438 Turn the corner

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

  2. HDU2438:Turn the corner(三分)

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

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

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

  4. Turn the corner (三分)

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

  5. hdu 1577 WisKey的眼神 (数学几何)

    WisKey的眼神 Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total S ...

  6. Turn the corner

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

  7. Turn the corner

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

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

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

  9. hdu 1115 Lifting the Stone (数学几何)

    Lifting the Stone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...

随机推荐

  1. Markdown---语法小记

    在CSDN上的文章如今都习惯使用Markdown来编写比較方便美观.这里小结下常见的Markdown语法下: 1.标题: 方式1 # H1 ## H2 ### H3 #### H4 ##### H5 ...

  2. RecyclerView实现瀑布流布局

    RecyclerView本身提供了三个LayoutManager的实现 LinearLayoutManager GridLayoutManager StaggeredGridLayoutManager ...

  3. C#与Linux守护进程

    用C#编写Linux守护进程   如果要在Red Hat Enterprise Linux上将.NET Core进程作为后台进程运行,则可以创建自定义systemd单元.今天我将为.NET Core编 ...

  4. Mysql主从级联复制

    场景1 如果主节点已经运行了一段时间,且有大量数据时,如何配置并启动slave节点 通过备份恢复数据至从服务器· 复制起始位置为备份时,二进制日志文件及其POS: Mater 设置 1) 修改配置文件 ...

  5. PHP 获取完整URL地址

    /** * 获取当前完整URL * @return string */ function get_url() { $sys_protocal = isset($_SERVER['SERVER_PORT ...

  6. nohup---将程序以忽略挂起信号的方式运行起来

    nohup nohup命令:如果你正在运行一个进程,而且你觉得在退出帐户时该进程还不会结束,那么可以使用nohup命令.该命令可以在你退出帐户/关闭终端之后继续运行相应的进程. 在缺省情况下该作业的所 ...

  7. .Net 开源控件 NPlot使用小结

    NPlot是一款非常难得的.Net平台下的图表控件,能做各种曲线图,柱状图,饼图,散点图,股票图等,而且它免费又开源,使用起来也非常符合程序员的习惯.授权方式为BSD许可证. 下载链接: http:/ ...

  8. [Python's] Python's list comprehensions a

    # Python's list comprehensions are awesome. vals = [expression for value in collection if condition] ...

  9. 源代码编译安装CloudStack 4.2

    基于CentOS 6.4安装CloudStack 环境配置 # yum -y update # yum -y upgrade 安装NTP,jdk 1.7, tomcat 6, mysql,git等服务 ...

  10. 洛谷 P2026 求一次函数解析式

    P2026 求一次函数解析式 题目背景 做数学寒假作业的怨念…… 题目描述 给定两个整点的坐标,求它们所在直线的函数解析式(一次函数). 输入输出格式 输入格式: 输入共两行. 第一行有两个整数x1, ...