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?

the corner" title="Turn 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
题意:西先生开始出去,遇到一个弯,让你求能不能拐过去;
解题思路:假设过弯时l与底边夹角为s,用三分求最理想过弯角度(用过弯过程中与转弯之后的宽度y相比较),找到最合适的角度,如果最合适的角度,转弯的宽度还是比y大就肯定转不过去,反之就能转过去;
感悟:寻找过弯条件是最难的,找到之后就简单多了,记录第二道三分题;
代码(G++
0ms):
#include

#include

#include

#define pi 3.141592653589793238

using namespace std;



double x,y,l,d;

double cal(double s)//进行三分的条件

{

    return
l*cos(s)+(d-x*cos(s))/(sin(s));

   
//l*cos(s)+(d-x*cos(s))/(sin(s))就是过弯过程中在y方向上的宽

}

int
main()

{

   
//freopen("in.txt", "r", stdin);

    double
left,right,mid,midmid;

   
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)

    {

       
//printf("x=%.1f y=%.1f l=%.1f d=%.1f\n",x,y,l,d);

       
if(d>x||d>y)

       
{

           
printf("no\n");

           
continue;

       
}

       
left=0;

       
right=pi/2;//最大只能是pi/2,不可能倒着转弯吧

       
//printf("left=%.1f right=%.1f\n",left,right);

       
while (right-left>1e-10)

       
{

           
mid=(left+right)/2;

           
midmid=(mid+right)/2;

           
//printf("mid=%.4f mid mid=%.4f\n",mid,midmid);

           
if (cal(mid)>=cal(midmid))//过弯过程中在y方向上的宽,与y比较

               
right=midmid;

           
else left=mid;

       
}

       
//printf("right=%.1f\n",right);

       
if(cal(right)>y)//如果最大角度过弯时还是比y宽就肯定过不去

           
printf("no\n");

       
else

           
printf("yes\n");

    }

    return
0;

}

Turn the corner的更多相关文章

  1. Turn the corner (三分)

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

  2. Turn the corner

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

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

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

  4. hdu 2348 Turn the corner(三分&&几何)(中等)

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

  5. hdu 2438 Turn the corner [ 三分 ]

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

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

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

  7. hdu 2438 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

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

  9. hdu Turn the corner

    这题是道三分的题,首先要分析满足条件的情况,这个就是平面几何的功夫了.要想车子能够转弯成功,最上面那个点到水平线的距离要小于等于y.这里h和s的公式就是利用平面几何的知识求出来的:s=l*cos(a) ...

随机推荐

  1. 极化码之tal-vardy算法(2)

    上一节我们了解了tal-vardy算法的大致原理,对所要研究的二元输入无记忆对称信道进行了介绍,并着重介绍了能够避免输出爆炸灾难的合并操作,这一节我们来关注信道弱化与强化操作. [1]<Chan ...

  2. 关于C++中char 型变量的地址输出

    在刚开始学习C/C++过程中,我们希望输出各个变量的地址来窥探一些我们"百思不得其解"的现象,例如搞清函数堆栈相关的程序内部秘密. 先看下面示例: #include<stdi ...

  3. mac 安装Beautiful Soup

    Beautiful Soup是一个Python的一个库,主要为一些短周期项目比如屏幕抓取而设计.有三个特性使得它非常强大: 1.Beautiful Soup提供了一些简单的方法和Python术语,用于 ...

  4. 实例讲解webpack的基本使用第二篇

    这一篇来讲解一下如何设置webpack的配置文件webpack.config.js 我们新建一个webpack-demo的项目文件夹,然后安装webpack 执行如下命令 在项目文件夹下,建一个dis ...

  5. 18.Llinux-触摸屏驱动(详解)

    本节的触摸屏驱动也是使用之前的输入子系统 1.先来回忆之前第12节分析的输入子系统 其中输入子系统层次如下图所示, 其中事件处理层的函数都是通过input_register_handler()函数注册 ...

  6. You Are the One DP

    You Are the One Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  7. Linux查找和筛选工具

    本文为原创文章,转载请标明出处 目录 文件名通配符 单字符匹配元字符 ? 多字符匹配元字符 * 字符范围匹配符 [] 排除范围匹配符 [!] 命令中的正则表达式 单字符匹配符 . 单字符或字符串重复匹 ...

  8. Response.Write输出导致页面变形和页面白屏解决办法

    方法一:此方法应该是微软官方推荐的方法,但弹出时会造成页面白屏.Page.RegisterStartupScript("TestEvent", "<script&g ...

  9. C语言通过函数参数不能带出动态内存的例子。

    实验结论:通过函数参数不能带出动态内存,函数参数虽然为指针,其实是在函数内部的临时变量,只是该指针的初始值是通过调用函数赋值的.C语言函数参数都是传值的. #include <stdio.h&g ...

  10. Github Page+Bmob实现简单动态功能

    Github Page基于jekyll能够实现简单的静态网站,但是没有提供后端服务.目前国内外也有很多提供后台服务,特别是云服务.譬如国外有AWS,记得好像是注册免费使用一年:再如Heroku,支持N ...