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. 12 Nonlinear Transformation

    一.二次假设 实际上线性假设的复杂度是受到限制的, 需要高次假设打破这个限制 假设数据不是线性可分的,但是可以被一个圆心在原点的圆分开, 需要我们重新设计基于该圆的PLA等算法吗 不用, 只需要通过非 ...

  2. Spring-boot:5分钟整合Dubbo构建分布式服务

    概述: Dubbo是Alibaba开源的分布式服务框架,它最大的特点是按照分层的方式来架构,使用这种方式可以使各个层之间解耦合(或者最大限度地松耦合).从服务模型的角度来看,Dubbo采用的是一种非常 ...

  3. Count(*), Count(1) 和Count(字段)的区别

    1.  count(1) and count(*) 当表的数据量大些时,对表作分析之后,使用count(1)还要比使用count(*)用时多了!  从执行计划来看,count(1)和count(*)的 ...

  4. Bayesian CTR Prediction for Bing

    Microsoft published a paper in ICML 2009 named ‘Web-Scale Bayesian Click-Through Rate Prediction for ...

  5. 在Kubernetes集群中使用calico做网络驱动的配置方法

    参考calico官网:http://docs.projectcalico.org/v2.0/getting-started/kubernetes/installation/hosted/kubeadm ...

  6. Web服务器自定义错误页面

    在使用Web服务器运行程序的时候,难免会出现诸如 404.500 等错误,那么如何针对不同的错误代码来自定义错误页面呢? 1.找到web项目的 web.xml 文件打开,添加以下标签代码,规则是 er ...

  7. 运用 finereport 和 oracle 结合开发报表思路大总结

    近排自己学习了一款软件finereport开发报表模块,自己总结了如何了解需求,分析需求,再进行实践应用开发,最后进行测试数据的准确性,部署报表到项目对应的模块中显示. 一.需求(根据需求文档分析) ...

  8. 搭建Hadoop平台(新手入门)

    刚刚大学毕业,接触大数据有一年的时间了,把自己的一些学习笔记分享给大家,希望同热爱大数据的伙伴们一起学习,成长! 资料准备: Hadoop-2.7.1下载:http://pan.baidu.com/s ...

  9. Linux系列教程(一)——Linux系统简介

    本系列教程将完整的讲解整个Linux相关的知识,这是楼主学完之后重新对Linux知识体系的整理.从最基础的知识开始,对于一个完全不懂Linux系统的人,相信在看完整个系列教程之后,都能对Linux有一 ...

  10. linux 远程操作(expect)

    Expect是在Tcl基础上创建起来的,它还提供了一些Tcl所没有的命令,它可以用来做一些linux下无法做到交互的一些命令操作,在远程管 理方面发挥很大的作用. spawn命令激活一个Unix程序来 ...