这题是道三分的题,首先要分析满足条件的情况,这个就是平面几何的功夫了。要想车子能够转弯成功,最上面那个点到水平线的距离要小于等于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. Http 协议Header

    Responses 部分 Header 解释 示例 Accept-Ranges 表明服务器是否支持指定范围请求及哪种类型的分段请求 Accept-Ranges: bytes Age 从原始服务器到代理 ...

  2. php 今天 昨天 明天 时间戳

    2013年9月10日 16:26:25 echo strtotime('now'),'<br>'; echo strtotime('today'),'<br>'; echo s ...

  3. Java for LeetCode 139 Word Break

    Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...

  4. CodeForces - 404B(模拟题)

    Marathon Time Limit: 1000MS   Memory Limit: 262144KB   64bit IO Format: %I64d & %I64u Submit Sta ...

  5. kail ip配置

    设置ip /etc/network/interfaces # This file describes the network interfaces available on your system # ...

  6. Txx考试(codevs 2894)

    2894 Txx考试  时间限制: 1 s  空间限制: 32000 KB  题目等级 : 黄金 Gold 题解  查看运行结果     题目描述 Description Txx是一个成绩很差的人,考 ...

  7. Zabbix利用msmtp+mutt发送邮件报警(公告:这文章有问题,还没有修改,2016-08-25)

    [root@86 ~]# wget http://jaist.dl.sourceforge.net/project/msmtp/msmtp/1.4.32/msmtp-1.4.32.tar.bz2 百度 ...

  8. Python中通过cx_oracle操作ORACLE数据库的封闭函数

    哈哈,看来我的SQL自动化发布,马上就全面支持ORACLE,MYSQL,POSTGRESQL,MSSQL啦... http://blog.csdn.net/swiftshow/article/deta ...

  9. Sonar+Hudson+Maven构建系列之三:安装Hudson

    摘要:其实前面介绍过Sonar,后面Hudson安装就方便了.安装Hudson之前说说Hudson相关的事,现在世面上的有两种与Hudson相关的CI工具,一个是Hudson,一个是Jenkins,这 ...

  10. MS SQL SERVER 2000 常用 Tran-SQL 语句

    一.创建数据库:create database mydb-创建数据库mydbon primary-在primary文件组中( name = mydb_data1,filename = 'd:\sql ...