1005 of search
来源:互联网 发布:kmp算法匹配过程 编辑:程序博客网 时间:2024/06/03 21:22
Turn the corner
Time Limit : 3000/1000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 57 Accepted Submission(s) : 31
Problem Description
Mr. West bought a new car! So he is travelling around the city.<br><br>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.<br><br>Can Mr. West go across the corner?<br><img src=../../../data/images/2438-1.jpg><br>
Input
Every line has four real numbers, x, y, l and w.<br>Proceed to the end of file.<br>
Output
If he can go across the corner, print "yes". Print "no" otherwise.<br>
Sample Input
10 6 13.5 4<br>10 6 14.5 4<br>
Sample Output
yes<br>no<br>
Source
2008 Asia Harbin Regional Contest Online
题目要求:给出车辆的长宽和路转弯前后的宽度,问是否能够通过弯道。
解题思路:1通过定量分析可以看出转弯后的最大高度h是先减后增,所以用三分法可以完美的解决,得到最小高度h。
2用数学方法可以通过相似列出最小转弯后的高度h,然后和路宽比较即可。
#include<iostream>#include<cmath>#include<cstdio>using namespace std;double pi=acos(-1.0);double x,y,l,w,s,h;double f(double a){ s=l*cos(a)+w*sin(a)-x; h=s*tan(a)+w*cos(a); return h;}int main(){ double r,l1,m,mm; while(~scanf("%lf%lf%lf%lf",&x,&y,&l,&w)) { l1=0.0;r=pi/2; while(r-l1>1e-8) { m=(l1+r)/2; mm=(m+r)/2; if(f(m)>f(mm))r=mm; else l1=m; } if(f(m)<=y)printf("yes\n"); else printf("no\n"); }}
ps:三分法的关键是列出三角函数表达式,这需要一定的数学功底,由此看出数学对acm来说好处大大的。
0 0
- 1005 of search
- 1003 of search
- 1004 of search
- 1006 of search
- 1007 of search
- 1008 of search
- 1009 of search
- 1010 of search
- 1011 of search
- 1012 of search
- 1003 of search
- 1015 of search
- 1016 of search
- 1018 of search
- 1019 of search
- 1020 of search
- the summary of search
- Role of Internal Search
- 多线程编程中保证线程安全(1)
- Spark生态之Spark-csv学习1之安装和简单的examples
- jvm简介
- jQuery Ajax 调用WebService实例详解
- 安卓 属性动画 今天用到的 动画效果以及过程中的经验分享
- 1005 of search
- 【一天一道LeetCode】#10. Regular Expression Matching
- hdu-4717-The Moving Points三分
- with check option使用
- UVa567 Risk(floyd)
- Mysql学习(一) windows7 mysql5.7.12 noinstall安装
- 欧弈斌--厚道(说得太好了)!
- 【图像处理】C++实现模板匹配
- Jquery Validate验证