HDU 2438 Turn the corner(三分枚举角度)
来源:互联网 发布:淘宝csv导入怎么开发 编辑:程序博客网 时间:2024/05/21 12:55
题目大意:给你一个拐角,两边的路的宽度分别为x,y。汽车的长和宽分别为h,w。问你这个汽车否转弯成功。
解题思路:如图,枚举角度。
这是一个凸函数所以三分枚举角度。
Turn the corner
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2009 Accepted Submission(s): 765
Problem Description
Mr. West bought a new car! So he is travelling around the city.
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?
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?
Input
Every line has four real numbers, x, y, l and w.
Proceed to the end of file.
Proceed to the end of file.
Output
If he can go across the corner, print "yes". Print "no" otherwise.
Sample Input
10 6 13.5 410 6 14.5 4
Sample Output
yesno
Source
2008 Asia Harbin Regional Contest Online
#include <iostream>#include<time.h>#include<stdio.h>#include<string.h>#include<stdlib.h>#include<string>#include<cmath>#include<map>#define eps 1e-10#define PI acos(-1)using namespace std;const int maxn = 220;#define LL long longdouble x, y, l, w;double Del(double ang){ double s = l*cos(ang)+w*sin(ang)-x; double h = s*tan(ang)+w*cos(ang); return h;}int main(){ while(cin >>x>>y>>l>>w) { double Max = 0.0; double left = 0; double right = PI/2.0; while(right-left > eps) { double mid = (right+left)/2.0; double rmid = (mid+right)/2.0; double xp1 = Del(mid); double xp2 = Del(rmid); if(xp1 > xp2) right = rmid; else left = mid; Max = max(Max, max(xp1, xp2)); } if(Max > y) cout<<"no"<<endl; else cout<<"yes"<<endl; }}
0 0
- HDU 2438 Turn the corner(三分枚举角度)
- hdu 2438 - Turn the corner(三分)
- hdu 2438Turn the corner(三分)
- HDU 2438 Turn the corner(三分)
- hdu 2438 Turn the corner(三分)
- HDU 2438 Turn the corner(三分)
- hdu-2438-Turn the corner(三分)
- HDU 2438 Turn the corner 三分
- HDU 2438 Turn the corner【三分】
- HDU 2438 Turn the corner(三分)
- HDU 2438 Turn the corner 三分
- HDU 2438 Turn the corner (计算几何 + 三分)
- hdu 2438 计算几何 三分 Turn the corner
- HDU ACM 2438 ->Turn the corner 三分求最值
- HDU 2438 Turn the corner 计算几何+三分
- HDU 2438 Turn the corner (三分求极值)
- HDU 2438 Turn the corner 三角函数+三分查找法
- HDU 2438 Turn the corner(三分查找, 几何求解)
- php判断用户浏览器类型是否为微信浏览器
- Servlet 重定向传参
- jdbcTemplate的取值方法和注意事件
- 【iOS开发-120】在storyboard中如何使用Size Classes,其实就是设置多套AutoLayout
- iOS强制屏幕旋转
- HDU 2438 Turn the corner(三分枚举角度)
- android之GPS
- 关于UIScollectionView使用,字体打印,判断定位是否开启
- 闭包
- UVA Shoemaker's Problem
- phonegap 弹出框的样式出现差异的问题
- rsync远程同步备份数据(ssh方式)
- Content-type的说明即HTTP请求头的类型整理
- java &和&&的区别