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 ...
随机推荐
- svn cleanup失败
今天用SVN的时候出现被锁定的情况,既不能更新代码也不能提交. 解决方法如下: 1. 在被锁定的文件夹上点右键,找到并点击Clean up菜单项 2. 在Cleanup对话框中勾选“Break loc ...
- name是个特殊的变量名吗
这是为什么?求大神
- TIDB介绍 新数据库趋势
TIDB是什么? TIDB 受谷歌Spanner和F1的论文启发的new sql数据库,这类数据库不仅具有NoSQL对海量数据的存储管理能力,还保持了传统数据库支持ACID和SQL等特性,同类数据库还 ...
- springboot项目访问不到controller方法。
访问不到方法首先要从你的controller能否被扫描到出发, 图中显示创建springboot项目自带的这两个的文件要注意把他俩拿出来放到父包下面也就是图中这个位置.如果你的这两个文件在子包里或者说 ...
- WebRTC 学习资源 电子书 WebRTC权威指南 Learning WebRTC
webRTC源码下载地址:https://pan.baidu.com/s/18CjClvAuz3B9oF33ngbJIw 提取码:wl1e 1.<WebRTC权威指南>第三版 中文版 本书 ...
- springmvc搭建环境时报No mapping found for HTTP request with URI [/exam3/welcome] in DispatcherServlet with name 'spring2'
项目是使用spring MVC (1)在浏览器中访问,后台总报错: No mapping found for HTTP request with URI [/exam3/welcome] in Dis ...
- office 2013 快速换KEY
在有些时候,我们总会碰到一些需要更换Office安装Key(序列号.密钥)的情形,例如购买或朋友赠了新的Key等等.网上搜索的话,有很多种更改变换Office 2010序列号办法,今天就来挨个介绍一下 ...
- mock数据和代码生成
git clone https://gitee.com/fleam/CodeGeneration.git
- 关于Unity中Time.deltaTime的使用
例子 void Update () { this.transform.Rotate(Vector3.up, Time.deltaTime * 50, Space.World); //绕世界的y轴旋转, ...
- 【Html】Vue动态插入组件
html: <div id="app"> <p>{{ message }}</p> <button @click="add('a ...