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 ...
随机推荐
- html语法之--使用图像映射
1 什么是图像映射所谓图像映射是指在一幅图中定义若干个区域,每个区域中指定一个不同的超链接,当单击不同的区域时便可以跳转到相应的目标页面. 2 创建图像映射 2.1 定义映射区域 定义映射区域使用MA ...
- 简易 Ajax 入门案例
AJAX = 异步 JavaScript 及 XML(Asynchronous JavaScript and XML) AJAX 不是一种新的编程语言,而是一种用于创建更好更快以及交互性更强的 Web ...
- web.config中<customErrors>节点
错误提示: “/”应用程序中的服务器错误.------------------------------------------------------------------------------- ...
- [原]性能优化之Hibernate缓存讲解、应用和调优
近来坤哥推荐我我们一款性能监控.调优工具--JavaMelody,通过它让我觉得项目优化是看得见摸得着的,优化有了针对性.而无论是对于分布式,还是非分布,缓存是提示性能的有效工具. 数据层是EJB3. ...
- iphone5升级到iOS7时出现“This device isn't eligible for the requested build”错误
因为工作的需要我需要把自己的手机升级到iOS7,安装苹果的升级顺序总是报This device isn't eligible for the requested build错误,搜索相关的文章我的错误 ...
- Redis的持久化选项
Redis提供了两种不同的持久化方法来将数据存储到硬盘里面.一种方法叫快照(snapshotting),它可以将存在于某一时刻的所有数据都写入硬盘里面.另一种方法叫只追加文件(append-only ...
- Java反射-简单应用
为了程序更好的维护和扩展,在面向对象思维的世界里,首先是面向接口编程,然后我们应该把做什么和怎么做进行分离. 以下我将用一个开晚会的样例来演示一下,终于达到的效果是:工厂+反射+配置文件实现程序的灵活 ...
- Java实现串口通信的小样例
用Java实现串口通信(windows系统下),须要用到sun提供的串口包 javacomm20-win32.zip.当中要用到三个文件,配置例如以下: 1.comm.jar放置到 JAVA_HOME ...
- 假设说这个世界不是真实存在的,仅仅是一段代码,迄今为止你发现了哪些bug?
给这个世界写代码的不是一个人,而是一个团队(这么大的项目,一个人开发不了).并且严重怀疑这个一个开源项目.开发人员被我们觉得是神,所以一神论是不正确的,众神论才是真理,且凡人是有机会成为神的(參悟神道 ...
- 高效的SQLSERVER分页查询(推荐)
Sqlserver数据库分页查询一直是Sqlserver的短板,闲来无事,想出几种方法,假设有表ARTICLE,字段ID.YEAR...(其他省略),数据53210条(客户真实数据,量不大),分页查询 ...