传送门

Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2081    Accepted Submission(s): 787

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
 
Source
 
Recommend
gaojie   |   We have carefully selected several similar problems for you:  2444 2441 2442 2443 2440
 
 
题解转一发:
http://www.cnblogs.com/wally/archive/2013/05/14/3077383.html
 

网上大牛思路:

可以根据边界,汽车已经转弯,设水平方向为x轴,垂直方向为y轴。

则汽车的内边界(靠近里面的边界)的直线方程式f(x)为:y=x*tan(a)+l*sin(a)+d/cos(a).其中a是汽车与x轴的夹角

当y=X时,求解出的-x即为汽车的内边界到y轴的距离h,若h小于Y即可转弯,若大于Y就不能转弯。
所以只需要利用方程式,求-x的最大值,即可判断能否通过。
由于f(x)是凸函数(随着x的增大y先增大后减小),所以,需要借助三分求解。

图示:

第一道三分求极值题啊!!!

Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
13216500 2015-03-23 09:01:02 Accepted 2438 0MS 1688K 946 B G++ czy
 #include <cstdio>
#include <cmath> using namespace std; const double mi = 1e-;
const double eps = 1e-;
const double pi = 4.0 * atan(1.0); double x,y,l,d; double cal(double a)
{
return (-x + l * sin(a) + d / cos(a)) / tan(a) ;
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
if(d>y || d>x){
printf("no\n");continue;
}
double low=,high = pi / ,mid,mmid;
double te1,te2;
while(high - low > mi)
{
mid = (low + high) / ;
mmid = (low + mid) / ;
te1 = cal(mid);
te2 = cal(mmid);
if(te1 > te2){
low = mmid;
}
else{
high = mid;
}
}
te1 = cal(low);
if(te1 < y){
printf("yes\n");
}
else{
printf("no\n");
}
}
}

hdu 2438 Turn the corner [ 三分 ]的更多相关文章

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

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

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

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

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

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

  4. Turn the corner (三分)

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

  5. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

  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

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

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

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

  9. HDU 4869 Turn the pokers(推理)

    HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...

随机推荐

  1. disconf 分布式配置

    摘要 为了更好的解决分布式环境下多台服务实例的配置统一管理问题,本文提出了一套完整的分布式配置管理解决方案(简称为disconf[4],下同).首先,实现了同构系统的配置发布统一化,提供了配置服务se ...

  2. CSS3常用属性浏览器兼容前缀

    1.检测网站https://gsnedders.html5.org/outliner/ 2.查询是否支持前缀http://caniuse.com 3.border-radius\box-shadow\ ...

  3. laravel权限控制Gate

    实现思想 注册 位置: app/Providers/AuthServiceProvider.php $permissions = \App\AdminPermission::all(); foreac ...

  4. 数据源引用 java:/comp/env

      编辑 删除 数据源引用 java:/comp/env 2012-01-28 15:59   ENC的概念: The application component environment is ref ...

  5. sql server 全部错误号详释

    0 操作成功完成. 1 功能错误. 2 系统找不到指定的文件. 3 系统找不到指定的路径. 4 系统无法打开文件. 5 拒绝访问. 6 句柄无效. 7 存储控制块被损坏. 8 存储空间不足,无法处理此 ...

  6. swfit:运算符重载 Operator Methods

    Operator Methods Classes and structures can provide their own implementations of existing operators. ...

  7. Codeforces 1076D——最短路算法

    题目 给你一个有n个顶点.m条边的无向带权图.需要擦除一些边使得剩余的边数不超过k,如果一个点在原始图到顶点1的最短距离为d,在删边后的图中到顶点的最短距离仍是d,则称这种点是 good.问如何删边, ...

  8. Web Server Notifier 是chrome网上商店的一个插件

    Web Server Notifier 是chrome网上商店的一个插件

  9. MySQL-05 用户管理

    学习目标 权限表及其用法 账户管理 权限管理 访问控制 权限表 MySQL权限表存放在MySQL数据库里,由mysql_install_db脚本初始化.这些MySQL权限表分别为user.db.pro ...

  10. OpenCV2:第六章 图像几何变换

    一.简介 图像的几何变换有距离变换 坐标映射 平移  镜像 旋转  缩放  仿射变换等 二.重映射 把一张图像重新排列像素,比如倒置 CV_EXPORTS_W void remap( InputArr ...