Turn the corner
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?

four real numbers, x, y, l and w.
Proceed to the end of file.
across the corner, print "yes". Print "no" otherwise.
4
4
0ms):
#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方向上的宽
}
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的更多相关文章
- Turn the corner (三分)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- Turn the corner
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- HDU 2438 Turn the corner(三分查找)
托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! ...
- hdu 2348 Turn the corner(三分&&几何)(中等)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 2438 Turn the corner [ 三分 ]
传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- HDU2438 Turn the corner【三分法】【数学几何】
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- hdu 2438 Turn the corner(几何+三分)
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
- 【三分法】hdu2438 Turn the corner
Problem Description Mr. West bought a new car! So he is travelling around the city.One day he comes ...
- hdu Turn the corner
这题是道三分的题,首先要分析满足条件的情况,这个就是平面几何的功夫了.要想车子能够转弯成功,最上面那个点到水平线的距离要小于等于y.这里h和s的公式就是利用平面几何的知识求出来的:s=l*cos(a) ...
随机推荐
- Redis的安装以及在项目中使用Redis的一些总结和体会
第一部分:为什么我的项目中要使用Redis 我知道有些地方没说到位,希望大神们提出来,我会吸取教训,大家共同进步! 注册时邮件激活的部分使用Redis 发送邮件时使用Redis的消息队列,减轻网站压力 ...
- python基础之七种运算符
废话不多说,上节说的是数据类型,本篇讲讲数据运算. 在算式"1+2"中,"1"和"2"被称为操作数,"+"被称为运算符 ...
- python和C语言混编的几种方式
Python这些年风头一直很盛,占据了很多领域的位置,Web.大数据.人工智能.运维均有它的身影,甚至图形界面做的也很顺,乃至full-stack这个词语刚出来的时候,似乎就是为了描述它. Pytho ...
- JSP入门 分页
<div> <% Integer pageNo = (Integer) request.getAttribute("pageNo"); ...
- C语言定义从URL中获取键值的接口
环境:centos7下,对客户端http请求进行解析,来获取有效键值(包括汉字). 头文件 /* 这是一份关于从Http请求信息中提取键值的接口声明的头文件 */ #ifndef _HEAD_H_ # ...
- Java字符串的匹配问题,String类的matches方法与Matcher类的matches方法的使用比较,Matcher类的matches()、find()和lookingAt()方法的使用比较
参考网上相关blog,对Java字符串的匹配问题进行了简单的比较和总结,主要对String类的matches方法与Matcher类的matches方法进行了比较. 对Matcher类的matches( ...
- 【机器学习实战】第6章 支持向量机(Support Vector Machine / SVM)
第6章 支持向量机 <script type="text/javascript" src="http://cdn.mathjax.org/mathjax/lates ...
- Windows下MySQL5.6.21安装步骤
01.把 mysql-advanced-5.6.17-winx64.zip 解压到自定义 D:\mysql-5.6.17-W64 或 D:\mysql-advanced-5.6.17-winx64 目 ...
- System.Object简介
Object中的公共方法解释: 公共方法: Equals: public class Object { public virtual Boolean Equals(Object obj) { //如果 ...
- vue2组件之select2调用
目前,项目中使用了纯前端的静态项目+RESTFul接口的模式.为了更好的对数据进行操作,前端使用了vue2的mvvm功能,但是由于不是单页面应用,所以,并没有涉及到其它的如vue-route等功能,也 ...