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

思路:看懂题意后就会知道,这个是让找最值得;首先就的有函数关系式; 根据p到许仙的距离和角a有关系是:

f(a)=L*cos(a)-((x-w*cos(a))/tan(a)-w*sin(a))=L*cos(a)+(w-x*cos(a))/sin(a);

之后进行三分查找就行了;如果函数的最大值大于y值,不能通过;否则,通过;

如下图:
代码:
#include <stdio.h>
#include <string>
#include<iostream>
#include <cstring>
#include <iomanip>
#include <cmath>
#define pi 3.1415926
#include <algorithm>
using namespace std;
double x,l,y,w,a,b,c;
double f(double t);
int main(){
while(cin>>x>>y>>l>>w)
{ a=0.0;
b=pi/2.0;
double mid,mmid;
while(b-a>1e-10){
mid=(a+a+b)/3.0;
mmid=(mid+2*b)/3.0;
if(f(mid)>f(mmid))
b=mmid;
else
a=mid;
}
if(f(a)>y)
cout<<"no"<<endl;
else cout<<"yes"<<endl;
}
return 0;
}
double f(double t){
return l*cos(t)+(w-x*cos(t))/(sin(t));
}

hdu 2438的更多相关文章

  1. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

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

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

  3. hdu 2438 Turn the corner [ 三分 ]

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

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

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

  5. HDOJ(2438)几何里的三分

    Turn the corner http://acm.hdu.edu.cn/showproblem.php?pid=2438 题目:一辆车能否在一个路口拐弯,看图就很明白啦. 算法:见下图,只要求出图 ...

  6. HDU——PKU题目分类

    HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...

  7. [转] HDU 题目分类

    转载来自:http://www.cppblog.com/acronix/archive/2010/09/24/127536.aspx 分类一: 基础题:1000.1001.1004.1005.1008 ...

  8. HDU ACM 题目分类

    模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 104 ...

  9. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

随机推荐

  1. POJ2739 Sum of Consecutive Prime Numbers(尺取法)

    POJ2739 Sum of Consecutive Prime Numbers 题目大意:给出一个整数,如果有一段连续的素数之和等于该数,即满足要求,求出这种连续的素数的个数 水题:艾氏筛法打表+尺 ...

  2. php 之 文件操作(0524)

    php中文件包含两种:文件,文件夹.文件夹又称目录 新建一个文件aa.txt和一个文件夹text,text文件夹下又包含bb.txt 一.判断文件类型filetype("./aa.txt&q ...

  3. 为什么ELF文件的加载地址是0x8048000

    在一个进程的虚拟地址空间中,ELF文件是从0x8048000这个地址开始加载的,为什么会是这个地址? 回答:用命令ld --verbose可以看到0x08048000,ld的默认脚本用这个地址作为EL ...

  4. Sogou搜狗搜索引擎登录网站 - Blog透视镜

    Sogou搜狗是中国搜狐旗下的搜索引擎,其登录方式也很简单,只要输入网址,验证码即可,不需要注册账号,再进行登录,其他非 * 必填的字段,可留下空白不填,验证码只有4码,也很清晰可见,不像有的网站,即 ...

  5. (摘)ORACLE DBA的职责

    ORACLE数据库管理员应按如下方式对ORACLE数据库系统做定期监控: (1). 每天对ORACLE数据库的运行状态,日志文件,备份情况,数据 库的空间使用情况,系统资源的使用情况进行检查,发现并解 ...

  6. Unity3D中C#编写脚本

    1.继承MonoBehaviour类:任何一个游戏脚本都需要去继承MonoBehaviour这个类,只是在创建javascript脚本的时候,系统会将其类名与继承关系隐藏起来. 2.声明变量:使用Ja ...

  7. ASP.NET页面事件顺序

    当一个页面请求发送到WEB服务器时,不论该事件是由页面提交还是由页面重定向而激发的,页面在其被创建到释放的过程中都会运行一系列的事件.一个ASP.NET页面从悲怆见到释放的过程包含10个事件. (1) ...

  8. photoshop sdk

    http://blogs.adobe.com/photoshop/2013/09/introducing-adobe-generator-for-photoshop-cc.html

  9. SQL之用户自定义函数

    关于SQL Server用户自定义的函数,有标量函数.表值函数(内联表值函数.多语句表值函数)两种. 题外话,可能有部分朋友不知道SQL Serve用户自定义的函数应该是写在哪里,这里简单提示一下,在 ...

  10. Android实现摇晃手机的监听

     摘自:http://blog.csdn.net/xwren362922604/article/details/8515343 监听摇晃手机的类: /**  * @author renxinwei ...