这题是道三分的题,首先要分析满足条件的情况,这个就是平面几何的功夫了。要想车子能够转弯成功,最上面那个点到水平线的距离要小于等于y。这里h和s的公式就是利用平面几何的知识求出来的:s=l*cos(a)+w*sin(a)-x;s=l*cos(a)+w*sin(a)-x;其中s为最右边的那个点到拐角处的水平距离。因为角度和高度h满足凸函数的关系,因此想到利用角度采用三分的方法进行求解。

#include"iostream"
#include"stdio.h"
#include"algorithm"
#include"string.h"
#include"cmath"
#define exp 1e-8
#define pi acos(-1.0)
using namespace std;
double x,y,l,w;
double cal(double a)
{
double s=l*cos(a)+w*sin(a)-x;
double s=l*cos(a)+w*sin(a)-x;
return h;
}
int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)==)
{
double left=;
double right=pi/;;
double mid,midmid;//三分
while(abs(right-left)>exp)
{
mid=(right+left)/;
midmid=(mid+right)/;
if(cal(mid)>=cal(midmid)) right=midmid;
else left=mid;
}
if(cal(mid)<=y) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return ;
}

hdu 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 [ 三分 ]

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

  4. hdu 2438Turn the corner 三分

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

  5. Turn the corner (三分)

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

  6. Turn the corner

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

  7. Turn the corner

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

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

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

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

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

随机推荐

  1. 【原创】sql:慎用【数字字段1 - 数字字段2】这样的sql(10-null = null)mysql

    如果只有一个表的情况下 a表: id num1,num2 1 10 5 2 10 0 3 20 0 select id, num1,num2,num1 - num2 AS subNum from a; ...

  2. poj_2674 弹性碰撞

    题目大意 给定一条直线,长度为L 表示区间[0, L].在直线上开始放置N个人,每个人有一个初始位置pos(用到直线上端点0的距离表示)和初始方向dir('p' 或 'P' 表示向端点L行走, 'n' ...

  3. ligureUI 刷新列求和

    dataGrid=$("#dataGrid").ligerGrid({ columns: [ {display:, align:'left' }, {display:, align ...

  4. 教官的游戏(codevs 2793)

    题目描述 Description 有N个学生刚吃完饭,准备出食堂. 国防学校有个规矩:必须2人一排或3人一列离开. 两个教官A,B轮流取2或3人,谁先取完谁就赢得游戏.(A先取) 若两人都用最优策略, ...

  5. Android主题换肤实现

    本系列文章主要是对一个Material Design的APP的深度解析,主要包括以下内容 基于Material Design Support Library作为项目整体框架.对应博文:Android ...

  6. index index.html index.htm index.php

    server { listen 80; server_name localhost; index index.html index.htm index.php;#前后顺序有关系,越在前优先级别越高 r ...

  7. 深入学习SQL的Limit语句

    一.基本语法 SQL的limit语法的如以下形式 SELECT * FROM table  LIMIT [offset,] rows | rows OFFSET offset 当省略offset的时候 ...

  8. 字符截取 支持UTF8/GBK

    );         $n = $tn = $noc = ;          || $t ==  || ( <= $t && $t <= )) {             ...

  9. 谈谈“色彩空间表示方法”——RGB、YUY2、YUYV、YVYU、UYVY、AYUV

    转自:http://bbs.chinavideo.org/viewthread.php?tid=4143 还可参考http://www.fourcc.org/yuv.php 小知识:RGB与YUV-- ...

  10. BZOJ1189: [HNOI2007]紧急疏散evacuate 二分+最大流

    1189: [HNOI2007]紧急疏散evacuate Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1132  Solved: 412[Submi ...