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. AngularJS指令的作用域

    参考文章:https://segmentfault.com/a/1190000002773689

  2. wordpress高级教程

    1.获取博客信息 <?php bloginfo(''); ?> // 显示博客的信息 /* 部分常用参数: default:默认 name:名称 description:说明 url.ho ...

  3. QM项目开发文档整理

    QM项目开发文档整理 前言 在W公司工作4个多月,庆幸接触到的全是"硬"项目,真枪实干,技术.经验.能力都得到了很大提升. QM项目 此项目WEB前端学到的东西很多,对PHP项目的 ...

  4. instanceof操作符判断对象类型

    instanceof 的语法格式如下: myobject instanceof ExampleClass myobject:某类的对象引用 ExampleClass:某个类 class Quadran ...

  5. webpack ,react

    一小时包教会 —— webpack 入门指南 http://***/Article/50764   ------------------ 轻松入门React和Webpack http://www.in ...

  6. 一个ajax的后台controller

    @RequestMapping("/api/merBrand") @ResponseBody public ResultBrand merBrand(HttpServletRequ ...

  7. Unity 3D中的菜单项

    1.File菜单:主要是包含项目和场景的创建.保存以及输出等功能.2.Edit(编辑)菜单:只要包括对场景进行一系列的编辑以及环境设置操作等命令.3.Assets(资源)菜单:掌握资源在Unity中的 ...

  8. 使用NUnit进行项目的单元测试

    using System; using System.Collections; using System.Collections.Generic; using NUnit.Framework; nam ...

  9. cv:显示Linux命令运行进度

    cv: 显示 cp.mv 等命令的进度 2014-07-14 By toy Posted in Apps Edit on GitHub 在 Linux 系统中 , 大多数命令从来都是信奉 “ 沉默是金 ...

  10. BZOJ1106: [POI2007]立方体大作战tet

    1106: [POI2007]立方体大作战tet Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 419  Solved: 302[Submit][St ...