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

    一.用wubi安装ubuntu的时候自动重新下载 1.双击ubuntu.ios让windows加载这个镜像 2.断开网络 二.安装其他程序时提示Error: Dependency is not sat ...

  2. Java for LeetCode 174 Dungeon Game

    The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. ...

  3. 转圈游戏(codevs 3285)

    题目描述 Description n 个小伙伴(编号从 0 到 n-1)围坐一圈玩游戏.按照顺时针方向给 n 个位置编号,从0 到 n-1.最初,第 0 号小伙伴在第 0 号位置,第 1 号小伙伴在第 ...

  4. AndroidDev站点推荐-zz

    Android-Dev-Bookmarks 项目目前可以生成书签文件导入到浏览器中了,ADB 站点上的内容也是一样的,方便在线浏览.现在内容更新开始按期发布同时也会有个简短的介绍,内容逐渐增多比较难直 ...

  5. HTML 调用iscroll.js主要事项

    iscroll是一款很不错的滚动控件(js),但是在调用的时候,需要注意一些事项: 1.iscroll支持水平和垂直滚动,那么在调用的时候,一定注意滚动div必须大于父div,也就是说,父div的宽度 ...

  6. js checkbox

    js checkbox <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:/ ...

  7. Z.XML第二次迭代分数分配

    这是一篇简介的日志. 它关于二轮迭代Z-XML团队7名成员的分数分配. 每名成员的工作内容与之前的任务分工相同,即,大家都非常好的完成了计划的工作. 按照最初设定的分数分配原则,在今晚大家吃全家桶之前 ...

  8. Python实现的粒子群优化算法

    01.from numpy import array 02.from random import random 03.from math import sin, sqrt 04. 05.iter_ma ...

  9. Linphone iOS客户端编译时打开G729支持

    Assuming you were able to compile the SDK and the linphone XCode project, here is what you need to d ...

  10. js:数据结构笔记11--排序算法(1)

    基本准备: function CArray(numElems) { this.dataStore = []; this.pos = 0; this.numElems = numElems; this. ...