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. uva 280 - Vertex

    #include <iostream> #include <cstdio> using namespace std; #include <vector> #defi ...

  2. sql语句各种九九乘法表

    下面用while 和 if 条件写的SQL语句的四种九九乘法表 --9x9 左下角 ) BEGIN SET @S='' WHILE @J<=@I BEGIN )))))) END PRINT @ ...

  3. python 查看插件命令 pip freeze 以及django3.4链接mysql

    https://github.com/PyMySQL/PyMySQL/issues/244 pip freeze命令可以显示python插件版本 MySQLdb只支持Python2.*,还不支持3.* ...

  4. C++ 知识点1

    typedef的陷阱 严格来说typedef并不是定义别名,而是定义类型,比如typedef int a;按照大部分书本说来,就是把a看做int,这种说法初学看来是正确的,也易于理解,但是遇到type ...

  5. 自己写的简单的jQuery分页控件

    因为是内部项目,需要分页控件,网上找了一大堆,给领导一看,都说不行,原因很简单,太复杂,领导就想要个简单点的,类似百度的分页,可是自己也没写过Jquery控件,硬着头皮找了些资料,写了这个分页控件,目 ...

  6. sql server在使用xp_cmdshell

    一.sql server在使用xp_cmdshell读取远程服务器上的文件时,要先将远程服务器的目录映射到本地 代码: exec master..xp_cmdshell  'net use P: \\ ...

  7. document 写法

    # UfsProgressBar ## Component InfoA progress bar component of specified progress. ## Usage```<ufs ...

  8. Struts2学习笔记--Struts例子及开发流程

    参考资料:http://blog.csdn.net/hntyzgn2010/article/details/5547753 http://chenlh.iteye.com/blog/464341 入门 ...

  9. cf B. The Fibonacci Segment

    http://codeforces.com/contest/365/problem/B #include <cstdio> #include <cstring> #includ ...

  10. WCF服务实现客户端Cookie共享,表单验证的解决方案

    基于前几篇的文章,如果理解了通道 拦截器  服务转发的概念,相信你肯定也能理解咋的玩了. 说白了就是创建客户端的拦截器: 实现接口:IClientMessageInspector. 里面的方法就是客户 ...