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 ...
随机推荐
- 【oneday_onepage】—— 日常用语
what do you do for living? 一般用在问对方的工作.如果直接说“what is your job?”会显得有点生硬了. i was wondering if you can t ...
- JQuery控制radio选中和不选中方法总结
一.设置选中方法 代码如下: $("input[name='名字']").get(0).checked=true; $("input[name='名字']"). ...
- 关于sentinel LDK加密war包实现应用加密的使用方法
经过一周多时间的研究,终于对sentinel产品的使用有个基本的掌握.其中走了不少的弯路,特此记录一下,以备后面回顾. 开发前的用料准备: windows 10 x64位, tomcat7 x64bi ...
- Android Service和Binder、AIDL
1.首先理解service的作用和生命周期 由于activity如果切换,那么他就不再运行,那么我们想在玩游戏的时候听播放器中的音乐,activity就应运而生了,这是最常见的一种场景,同时servi ...
- Ogre 监听类与渲染流程
Ogre中有许多监听类,我们可以简单理解成C#中的事件,这些类作用都不小,说大点可能改变流程,说小点修改参数等,下面列举一些常用的监听类. FrameListener:由Ogre中的Root负责维护, ...
- 打开应用中SQLite文件的方法
1.先找到sdk中的platform-tools文件夹下的adb.exe 2.打开dos命令窗口依次输入 :adb shell → sqlite3 /data/data/com.example.s ...
- (笔记)linux增加非标波特率的方法
1.内核修改 涉及到的内核文件包括driver/char/tty_ioctl.c和arch/xx/include/asm/termbits.h 在linux内核中,struct ktermios结构的 ...
- android设置主mic/副mic录音
//添加MIC设置参数 /hal/audio_extn/audio_extn.c @@ -75,6 +75,7 @@ struct audio_extn_module { bool ras_enabl ...
- 第三百六十节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的基本概念
第三百六十节,Python分布式爬虫打造搜索引擎Scrapy精讲—elasticsearch(搜索引擎)的基本概念 elasticsearch的基本概念 1.集群:一个或者多个节点组织在一起 2.节点 ...
- Java如何合并两个数组?
Java中,如何合并两个数组? 示例 本例展示了如何使用List类的List.Addall(array1.asList(array2))方法和Array类的Arrays.toString()方法将两个 ...