Turn the corner (三分)
Turn the corner |
| Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
| Total Submission(s): 151 Accepted Submission(s): 61 |
|
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? |
|
Input
Every line has four real numbers, x, y, l and w.
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 4 |
|
Sample Output
yes
汽车拐弯问题,给定X, Y, l, d判断是否能够拐弯。 我们发现随着角度θ的增大,最大高度h先增长后减小,即为凸性函数,可以用三分法来求解。 这里的Calc函数需要比较繁琐的推倒公式: 3分搜索法 |
代码:
#include<stdio.h>
#include<string.h>
#include<math.h>
const double pi=*asin(1.0);
double x,y,l,d;
double geth(double an){
double s,h;
s=l*cos(an)-x+d*sin(an);//应该是减x因为车头要对住墙,然后看车尾最高是否大于y
h=s*tan(an)+d*cos(an);
return h;
}
double ABS(double a){
return a>=?a:-a;
}
void erfen(){
double l=,m,mm,r=pi/;
// printf("%lf\n",pi);
while(ABS(r-l)>1e-){
m=(l+r)/;
mm=(m+r)/;
if(geth(m)>=geth(mm))r=mm;
else l=m;
}
// printf("%lf\n",geth(m));
if(geth(l)>y)puts("no");
else puts("yes");
}
int main(){
while(~scanf("%lf%lf%lf%lf",&x,&y,&l,&d)){
erfen();
}
return ;
}
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 ...
- hdu 2348 Turn the corner(三分&&几何)(中等)
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- 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 2438Turn the corner 三分
Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 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 ...
- HDU2438:Turn the corner(三分)
传送门 分析 根据这张图,我们只要使得h<=y即可,可以发现h是一个凸函数,故使用三分,具体见代码 代码 #include<cstdio> #include<cstring&g ...
随机推荐
- Nginx 拒绝指定IP访问
来源 : http://www.ttlsa.com/nginx/nginx-deny-ip-access/ 闲来无事,登陆服务器,发现有个IP不断的猜测路径.试图往服务器上传文件(木马).于是查看 ...
- GO语言搭建
最近对GO语言产生了浓厚的兴趣.因为GO语言不仅仅可以开发桌面.web程序,最吸引我的是安卓大有往GO语言全方位靠拢的趋势,自家的系统还是用自家的语言开发比较靠谱. 用一句话来说:Go语言是谷歌200 ...
- 【Howie玩docker】-Centos 7 docker 启动容器iptables报No chain/target/match by that name
重启了一下服务器,以前能运行的docker网络应用都不能正常开启了. 因为用的是centos7,所以猜测有可能是iptables的问题. docker start 或者run 后总是提示类似的错误: ...
- 如何彻底卸载sql server 2012
好不容易装上了sql server 2012数据库,可是却不能连接本地的数据库,后来发现缺少一些服务,于是决定重新安装,但是卸载却很麻烦,如果卸载不干净的话,重新安装会出问题,所以下面就总结一些方法: ...
- Win7下qt5.3.1+opencv2.4.9编译环境的搭建(好多 Opencv2.4.9源码分析的博客)
到官网下载qt-opensource-windows-x86-mingw482_opengl-5.3.1.exe文件,执行该文件,选择默认安装即可实现QT的安装(安装在C盘的根目录下),该文件封装 ...
- 北广传媒RTMP流媒体服务器漏洞
北广传媒移动电视(http://www.bj-mobiletv.com/)的RTMP流媒体服务器有漏洞 该漏洞可以上我们通过他们的服务器向互联网直播视频 使用任意可以发布RTMP流媒体的客户端(例如: ...
- Android图片裁剪之自由裁剪
我的博客http://blog.csdn.net/dawn_moon 客户的需求都是非常怪的.我有时候在给客户做项目的时候就想骂客户是sb.可是请你相信我,等你有需求,自己变成客户的时候,给你做项目的 ...
- Canvas路径、描边、填充
<script> var context = document.getElementById('canvas').getContext('2d'); context.font = '48p ...
- 使用 AngularJS 从零构建大型应用
0.导言 1.准备工作 2.构建框架 3.丰富你的directives 4.公用的services 5.用controllers组织业务 导言 纵览线上各种AngularJS教程,大部分都是基础与一些 ...
- WP8.1开发系列之隐藏顶部状态栏
StatusBar statusbar = StatusBar.GetForCurrentView(); await statusbar.HideAsync(); 只能在后台代码中实现,前台xaml不 ...

