hdu 2348 Turn the corner(三分&&几何)(中等)
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2229 Accepted Submission(s): 856
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?
Proceed to the end of file.
10 6 13.5 4
10 6 14.5 4
yes
no
题意:
已知汽车的长和宽,l和w。以及俩条路的宽为x和y。汽车所处道路宽为x 。问汽车是否能顺利转弯?
分析:汽车是否能顺利转弯取决于在极限情况下,随着角度的变化,汽车离对面路的距离是否大于等于0
如图中
代码:
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
using namespace std;
#define pi 3.141592653
double x,y,l,w;
double cal(double a)
{
double s=l*cos(a)+w*sin(a)-x;
double h=s*tan(a)+w*cos(a);
return h;
}
int main()
{
while(scanf("%lf %lf %lf %lf",&x,&y,&l,&w)!=EOF)
{
double left=0.0,right=pi/2;
double lm,rm;
while(fabs(right-left)>1e-6)
{
lm=(left*2.0+right)/3.0;
rm=(left+right*2.0)/3.0;
if(cal(lm)>cal(rm))
right=rm;
else left=lm;
}
if(cal(left)<=y)
printf("yes\n");
else printf("no\n");
}
return 0;
}
hdu 2348 Turn the corner(三分&&几何)(中等)的更多相关文章
- HDU 2438 Turn the corner(三分查找)
托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! ...
- hdu 2438 Turn the corner [ 三分 ]
传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- 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(几何+三分)
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
- hdu 2438Turn the corner 三分
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 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【三分法】【数学几何】
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 4869 Turn the pokers(推理)
HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...
- Turn the corner
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
随机推荐
- js 的数值限制可能引起的问题
源于:https://raw.github.com/ruanyf/jstutorial/gh-pages/grammar/number.md 1. 根据国际标准IEEE 754,64位浮点数格式的64 ...
- PCL滤波介绍(1)
在获取点云数据时 ,由于设备精度,操作者经验环境因素带来的影响,以及电磁波的衍射特性,被测物体表面性质变化和数据拼接配准操作过程的影响,点云数据中讲不可避免的出现一些噪声.在点云处理流程中滤波处理作为 ...
- .gitignore不生效解决办法
.gitignore只能忽略那些原来没有被track的文件,如果某些文件已经被纳入了版本管理中,则修改.gitignore是无效的.那么解决方法就是先把本地缓存删除(改变成未track状态),然后再提 ...
- R中ifelse、which、%in%的用法
R中ifelse.which.%in%的用法 (2014-02-08 13:54:08)标签: 教育 在R学习过程中,遇到了ifelse.which.%in%,下面分别举例,说明他们的用法.1.ife ...
- 安卓程序代写 网上程序代写[转]eclipse快捷键
F 键类 F2 显示详细信息 F3 跳到声明或定义的地方 Ctrl + 键类 Ctrl+1 快速修复 ( 最经典的快捷键 , 就不用多说了 ) Ctrl+D 删除当前行 Ctrl+E 快速显示当前 E ...
- [spark 快速大数据分析读书笔记] 第一章 导论
[序言] Spark 基于内存的基本类型 (primitive)为一些应用程序带来了 100 倍的性能提升.Spark 允许用户程序将数据加载到 集群内存中用于反复查询,非常适用于大数据和机器学习. ...
- UPNP
基本概念 UPnP 的应用范围非常大,以致足够可以实现许多现成的.新的及令人兴奋的方案,包括家庭自动化.打印.图片处理.音频 / 视频娱乐.厨房设备.汽车网络和公共集会场所的类似网络.它可以充分发挥 ...
- Python之使用PIL实现cv2
有时候使用cv2需要安装opencv,但是opencv安装比较麻烦,因为需要编译过程. 所以,我们可以使用PIL对cv2的一些常用接口进行复现. 这里我们实现了cv2的imread(), imwrit ...
- Html中怎么用CSS让ul中多个li标签不换行横排显示
布局 通常有三种方式 { 1. position 2. float: left --> 其次是这个 3. block: inline-block --> 他们推荐我用这个 } 具体描述 ...
- Kali配置网卡静态信息
临时配置ip ifconfig eth0 up //端口启用 ifconfig eth0 down //端口关闭 ifconfig eth0 192.168.1.10 //只修改ip地址 ifconf ...