hdu 2438 Turn the corner [ 三分 ]
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2081 Accepted Submission(s): 787
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 14.5 4
no
网上大牛思路:
可以根据边界,汽车已经转弯,设水平方向为x轴,垂直方向为y轴。
则汽车的内边界(靠近里面的边界)的直线方程式f(x)为:y=x*tan(a)+l*sin(a)+d/cos(a).其中a是汽车与x轴的夹角
当y=X时,求解出的-x即为汽车的内边界到y轴的距离h,若h小于Y即可转弯,若大于Y就不能转弯。
所以只需要利用方程式,求-x的最大值,即可判断能否通过。
由于f(x)是凸函数(随着x的增大y先增大后减小),所以,需要借助三分求解。
图示:
第一道三分求极值题啊!!!
Run ID | Submit Time | Judge Status | Pro.ID | Exe.Time | Exe.Memory | Code Len. | Language | Author |
13216500 | 2015-03-23 09:01:02 | Accepted | 2438 | 0MS | 1688K | 946 B | G++ | czy |
#include <cstdio>
#include <cmath> using namespace std; const double mi = 1e-;
const double eps = 1e-;
const double pi = 4.0 * atan(1.0); double x,y,l,d; double cal(double a)
{
return (-x + l * sin(a) + d / cos(a)) / tan(a) ;
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
if(d>y || d>x){
printf("no\n");continue;
}
double low=,high = pi / ,mid,mmid;
double te1,te2;
while(high - low > mi)
{
mid = (low + high) / ;
mmid = (low + mid) / ;
te1 = cal(mid);
te2 = cal(mmid);
if(te1 > te2){
low = mmid;
}
else{
high = mid;
}
}
te1 = cal(low);
if(te1 < y){
printf("yes\n");
}
else{
printf("no\n");
}
}
}
hdu 2438 Turn the corner [ 三分 ]的更多相关文章
- 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(几何+三分)
Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...
- Turn the corner (三分)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...
- codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)
B. The Meeting Place Cannot Be Change ...
- 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张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...
随机推荐
- hihocoder1133 二分·二分查找之k小数
思路: 类似于快排的分治算法. 实现: #include <iostream> #include <cstdio> #include <algorithm> #in ...
- laravel核心思想
服务容器.依赖注入.门脸模式 服务容器 容器概念 用来装一个个实例的对象,比如邮件类. IOC控制反转 IOC(Inversion of Control)控制反转,面向对象,可降低代码之间的耦合度,借 ...
- 做OJ项目时遇到的坑
1.js代码写在Dom加载前,导致highcharts在ie8能够显示,而ie高版本和其他浏览器不能显示 我的理解:由于IE8和其他浏览器的js解析机制不同,ie8是在等dom全部加载完才开始执行js ...
- Selenium私房菜系列--总章
前言 在这段期间,我一直在找关于服务器的端测试方案,自动化工具等等,无意间我发现了Selenium这个工具.在试用一段时间后,觉得Selenium确实是一个很不错的Web测试工具.在和强大的QTP比较 ...
- [转] Figuring out why my SVCHOST.EXE is at 100% CPU without complicated tools in Windows 7
(转自:Figuring out why my SVCHOST.EXE is at 100% CPU without complicated tools in Windows 7 - Scott Ha ...
- C# 递归读取XML菜单数据
在博客园注册了有4年了,很遗憾至今仍未发表过博客,趁周末有空发表第一篇博客.小生不才,在此献丑了! 最近在研究一些关于C#的一些技术,纵观之前的开发项目的经验,做系统时显示系统菜单的功能总是喜欢把数据 ...
- how to make a function from using global var to not using it
let say, we want to find the bottom left node in a tree.one way to do it is using global vars: /** * ...
- Image Is Everything LA2995
白书第一章例题6 构造.思维.几何. 分别从几个角度去看,有矛盾就删掉,最后遍历一下统计个数 方法证明:第一个方块肯定要删除.假设前k个必须删除,第k+1个矛盾出现,假如不删掉,矛盾将持续存在,故必须 ...
- Metinfo 5.3.19管理员密码重置漏洞复现
Metinfo 5.3.19管理员密码重置漏洞 操作系统:Windows 10专业版 kali linux 网站环境:UPUPW 5.3 使用工具:burpsuite 1.7 beta 漏洞分 ...
- No-3.Linux 终端命令格式
Linux 终端命令格式 01. 终端命令格式 command [-options] [parameter] 说明: command:命令名,相应功能的英文单词或单词的缩写 [-options]:选项 ...