Turn the corner

Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 151 Accepted Submission(s): 61
 
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
 

汽车拐弯问题,给定X, Y, l, d判断是否能够拐弯。

我们发现随着角度θ的增大,最大高度h先增长后减小,即为凸性函数,可以用三分法来求解。

这里的Calc函数需要比较繁琐的推倒公式:
s = l * cos(θ) + w * sin(θ) - x;
h = s * tan(θ) + w * cos(θ);
其中s为汽车最右边的点离拐角的水平距离, h为里拐点最高的距离, θ范围从0到90。

3分搜索法

代码:

 #include<stdio.h>
#include<string.h>
#include<math.h>
const double pi=*asin(1.0);
double x,y,l,d;
double geth(double an){
double s,h;
s=l*cos(an)-x+d*sin(an);//应该是减x因为车头要对住墙,然后看车尾最高是否大于y
h=s*tan(an)+d*cos(an);
return h;
}
double ABS(double a){
return a>=?a:-a;
}
void erfen(){
double l=,m,mm,r=pi/;
// printf("%lf\n",pi);
while(ABS(r-l)>1e-){
m=(l+r)/;
mm=(m+r)/;
if(geth(m)>=geth(mm))r=mm;
else l=m;
}
// printf("%lf\n",geth(m));
if(geth(l)>y)puts("no");
else puts("yes");
}
int main(){
while(~scanf("%lf%lf%lf%lf",&x,&y,&l,&d)){
erfen();
}
return ;
}

Turn the corner (三分)的更多相关文章

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

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

  2. hdu 2438 Turn the corner [ 三分 ]

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

  3. hdu 2348 Turn the corner(三分&amp;&amp;几何)(中等)

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

  4. Turn the corner

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

  5. HDU2438 Turn the corner【三分法】【数学几何】

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

  6. hdu 2438Turn the corner 三分

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  7. Turn the corner

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

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

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

  9. HDU2438:Turn the corner(三分)

    传送门 分析 根据这张图,我们只要使得h<=y即可,可以发现h是一个凸函数,故使用三分,具体见代码 代码 #include<cstdio> #include<cstring&g ...

随机推荐

  1. eclipse 快捷键汇总

    1几个最重要的快捷键 代码助手:Ctrl+Space(简体中文操作系统是Alt+/)快速修正:Ctrl+1单词补全:Alt+/打开外部Java文档:Shift+F2 显示搜索对话框:Ctrl+H快速O ...

  2. caffe 配置 札记

    cudnn的配置 1. 安装前请去先官网下载cuDNN (cudnn-7.0-linux-x64-v3),建议安装v3,v4有些问题. 将cudnn-7.0-linux-x64-v3解压后会有两个文件 ...

  3. The number of positions

    Description The number of positions time limit per test: 0.5 second memory limit per test: 256 megab ...

  4. 走进C标准库(7)——"string.h"中函数的实现memcmp,memcpy,memmove,memset

    我的memcmp: int memcmp(void *buf1, void *buf2, unsigned int count){ int reval; while(count && ...

  5. git/github 笔记

    2016-1-9 创建github repos并提交修改 在[这里](https://github.com/new)创建一个repos, 进入终端,cd到一个目录下,这个目录用来放等下clone的工程 ...

  6. 详述USB OTG发展及协议标准

    USB On-The-Go 扩大了USB 的应用领域,将USB 从传统的PC 与外设通讯的模式,扩展到移动电子和嵌入式领域中,抛开主机PC,实现通常的外设与外设之间点对点(Point to Point ...

  7. Silverlight Socket 实现收发信息

    原文 http://www.cnblogs.com/ZetaChow/archive/2009/05/16/2237347.html 刚接触Silverlight的时候,除了其异步应用WCF.流媒体. ...

  8. 前端工程师须知pc电脑端分辨率

    PC端 按屏幕宽度大小排序(主流的用橙色标明) 分辨率   比例 | 设备尺寸 1024*500 (8.9寸) 1024*768 (比例4:3  | 10.4寸.12.1寸.14.1寸.15寸; ) ...

  9. asp.net Listbox控件用法

    2008-02-18 19:56 来源: 作者: ListBox(列表框)控件可以显示一组项目的列表,用户可以根据需要从中选择一个或多个选项.列表框可以为用户提供所有选项的列表.虽然也可设置列表框为多 ...

  10. SQL学习之组合查询(UNION)

    1.大多数的SQL查询只包含从一个或多个表中返回数据的单条SELECT语句,但是,SQL也允许执行多个查询(多条SELECT语句),并将结果作为一个查询结果集返回.这些组合查询通常称为并或复合查询. ...