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) ...
随机推荐
- js学习要点
js 一.词法结构 1.区分大小写 2.注意 // 单行 /* 多行注释 */ 3.字面量(直接量 literal) 12 //数字 5.8 // 小数 "hello" 'hell ...
- NDK中android.mk文件的简单介绍和第三方库的调用
先贴一个样例,然后解释一下: LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE := mydjvuapi SRC_FILE_ ...
- PHP垃圾回收机制理解
使用的是"引用计数"方式进行回收.简单地理解的话,就是每个分配的内存区域都有一个计数器,记录有多少个变量指针指向这片内存.当指向该片内存的指针数量为0,那么该片内存区域就可以被回收 ...
- 计算机基础--Java中int char byte的关系
计算机基础--Java中int char byte的关系 重要:一个汉字占用2byte,Java中用char(0-65535 Unicode16)型字符来存字(直接打印输出的话是字而非数字),当然要用 ...
- HDFS源码分析之NameNode(3)————RpcServer
NameNodeRpcServer implements NamenodeProtocols NameNode支持核心即NameNodeRpcServer 实现ClientProtocol 支持客户 ...
- easyUI表单基础知识
easyUI创建异步提交表单 我们创建一个带有 name.email 和 phone 字段的表单.通过使用 easyui 表单(form)插件来改变表单(form)为 ajax 表单(form).表单 ...
- C# 7.0 新特性:本地方法
C# 7.0:本地方法 VS 2017 的 C# 7.0 中引入了本地方法,本地方法是一种语法糖,允许我们在方法内定义本地方法.更加类似于函数式语言,但是,本质上还是基于面向对象实现的. 1. 本地方 ...
- 英特尔:不再公布PC处理器多核睿频数据
据了解,以往英特尔官方有三个频率数据:基础主频:Turbo 2.0(多核)频率:以及Turbo 3.0(单核)频率.现在被隐匿的则是Turbo 2.0(多核)频率. 对此,英特尔在回应媒体时表示,给出 ...
- java web Servlet 学习笔记 -3 会话管理技术
Cookie和HttpSession 什么是会话: 用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 每个用户在使用浏览器与服务器进行会话的过 ...
- MySQL 高效查询
在“现场加号&预约排队”项目中,“号贩子排查任务”在线下测试的时候没有问题,但是线上后,由于线上的数据量较大,导致在执行查询的时系统崩溃:后来经过查找,发现写的sql不合理,查出了许多用不到的 ...