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. MySQL 数据库操作命令汇总

    此文全部都是基本的数据库语言 1.登陆到mysql >mysql -h hostname -u username -p 然后等待系统提示输入密码即可登陆.如果想在登陆的时候就选择好数据库,可以使 ...

  2. python中的redis定义

    redis官方介绍,python的redis客户端可以一处定义,处处使用.到底是不是这样呢?是不是只要在配置文件里定义一次,不管在哪都可以使用了? 下面用代码说明: import redis impo ...

  3. Pick two points at random from the interior of a unit square, what is the expected distance between them?

    My solution is as folllowing. This integration is hard to solve. I googled it, and found the result ...

  4. 深入理解7816(4)---关于T=1

    之前说过的T=0协议,基本上相当于是透明的数据,也就是说从应用的角度看,通过T=0传递的TPDU数据信息大都可以直接转换为对应的APD命令响应数据,“字节”是T=0协议最小的数据传输单元. 对于T=1 ...

  5. 【转】FAE及其发展前景

    原文网址:http://blog.sina.com.cn/s/blog_6e80c27b0100okd9.html FAE Field Application Engineer(现场应用工程师) ,其 ...

  6. 【转】Excel快捷键大全

    原文网址:http://www.bm8.com.cn/keyboard/excel.asp 显示和使用"Office 助手"注意 若要执行以下操作,"Microsoft ...

  7. Joomla 3.x. How to edit registration page

    Adding registration form fields In order to add new fields to the registration form, database and fi ...

  8. (3)tomcat源代码分析环境的搭建

    他山之石,可以攻玉. 要想了解tomcat,咱必须先搭建tomcat的环境,下载tomcat的源码,学习其架构. 1.首先是SVM  Import 2.创建新的资源库位置:http://svn.apa ...

  9. 自制USB wifi信号放大天线

    这是我的usb wifi天线第一个版本,灵感来自: http://www.instructables.com/id/EQARE4I72GEPUCHTHU/ http://www.usbwifi.orc ...

  10. Ext.window的close的问题

    以前每次都是用的hide,关闭后隐藏窗体,下一次点击再打开,这种方法在我的随笔里面有,可是现在遇到一个问题,我的窗体里面有个formpanel,formpanel每一项都有一个默认值,意思就是修改的时 ...