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. 后台构建 html 字符串传到前台字符串转码(html)处理

    知识在于总结,那就记下了吧! 例如后台 html 字符串是 var htmlStr="后台html字符串": 转码 var html格式代码=decodeHtml(htmlStr) ...

  2. js函数的各种写法与调用

    以下是我见过的各种js函数的各种写法以及调用,虽然有些写法及其调用我不清楚其专业术语叫啥,但并不影响我写一个总结笔记. 我们刚开始接触js语音,经常看到的这种名叫“使用function关键字来定义函数 ...

  3. php 字符编码转换函数 iconv mb_convert_encoding比较

    在使用PHP处理字符串时,我们经常会碰到字符编码转换的问题,你碰到过iconv转换失败吗? 发现问题时,网上搜了搜,才发现iconv原来有bug ,碰到一些生僻字就会无法转换,当然了配置第二个参数时, ...

  4. C语言初学 比较五个整数并输出最大值和最小值2

    #include <stdio.h> int main() { int i,a[5]; int max = 0,min = 0; printf("输入5个整数(空格隔开) :\n ...

  5. BufferedInputStream

    package file; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStrea ...

  6. 遗传算法matlab实现

    我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下运用MATLAB实现遗传算法:   clc clear   %参数 a = 0 ; b = 4 ; e ...

  7. substr vs substring

    javascript(js)中的 substring和substr方法 Posted on 2009-02-26 14:14 chinaifne 阅读(33698) 评论(0) 编辑 收藏 1.sub ...

  8. 给Qt生成的exe执行程序添加版本信息

    Windows下的.exe可执行文件的属性中有版本这个信息,含有版本信息.描述.版权等.对于qt程序,要含有这样的信息,那就请如下操作:新建<工程名>.rc文件,在rc文件填入下的信息: ...

  9. [转]ubuntu14.04安装好用的google拼音输入法

    原文网址:http://jingyan.baidu.com/article/219f4bf7d4a183de442d38f2.html 装了ubuntu14.04后感觉自带的拼音输入法不好用的有没有, ...

  10. Android 使用HorizontalScrollView 实现Gallery效果

    Gallery(画廊)是一个锁定中心条目并且拥有水平滚动列表的视图,一般用来浏览图片,并且可以响应事件显示信息:Gallery还可以和ImageSwitcher组件结合使用来实现一个通过缩略图来浏览图 ...