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 ...
随机推荐
- 超快速使用docker在本地搭建hadoop分布式集群
超快速使用docker在本地搭建hadoop分布式集群 超快速使用docker在本地搭建hadoop分布式集群 学习hadoop集群环境搭建是hadoop入门的必经之路.搭建分布式集群通常有两个办法: ...
- frame,iframe,frameset用法和区别
■ 框架概念 : 所谓框架便是网页画面分成几个框窗,同时取得多个 URL.只需要 <FRAMESET> <FRAME> 即可,而所有框架标记需要放在一个总起的 html 档,这 ...
- mud目录命令说明
目錄結構 以下列出的是 ES2 mudlib 根目錄下標準的子目錄結構,以及簡短的說明. /adm 儲存由系統管理者所管理的程式與資料檔. /std 儲存標準物件的程式碼. /obj 儲存通用物件 ...
- struts2笔记08-初识ActionSupport
1.配置一个最简单的action <action name="simple-action"> <result>/simple.jsp</result& ...
- binwalk windows安装和使用方法
binwalk是一个文件的分析工具,旨在协助研究人员对文件进行分析,提取及逆向工程.简单易用,完全自动化脚本,并通过自定义签名,提取规则和插件模块,还重要一点的是可以轻松地扩展. 以上是binwalk ...
- css 清除浮动 兼容IE+, FF
上代码: <!doctype html> <html> <head> <meta charset="utf-8"> <titl ...
- 6. java.lang.IllegalArgumentException
方法的参数错误 比如g.setColor(int red,int green,int blue)这个方法中的三个值,如果有超过255的也会出现这个异常,因此一旦发现这个异常,我们要做的,就是赶紧去检查 ...
- In-System Debugger for 8051 Devices(ISD 8051单片机在线调试器)
此文档包含了最新版本的说明及最近的更新特别是对 ISD51 的说明(用户手册没有此说明) Keil Software,Inc and Keil Elektronik GmbH保留所有此文件中涉及的信息 ...
- /etc/security/limits.conf 配置
<pre name="code" class="python">* soft nofile 65535 * hard nofile 65535 * ...
- UberX及以上级别车奖励政策(优步北京第一组)
优步北京第一组: 定义为2015年6月1日凌晨前(不含6月1日)激活的司机(以优步后台数据显示为准) 滴滴快车单单2.5倍,注册地址:http://www.udache.com/如何注册Uber司机( ...

