Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 2229    Accepted Submission(s): 856

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
10 6 14.5 4
 
Sample Output
yes
no

题意:

已知汽车的长和宽,l和w。以及俩条路的宽为x和y。汽车所处道路宽为x 。问汽车是否能顺利转弯?

分析:汽车是否能顺利转弯取决于在极限情况下,随着角度的变化,汽车离对面路的距离是否大于等于0

如图中

在上图中须要计算转弯过程中h 的最大值是否小于等于y非常明显。随着角度θ的增大,最大高度h先增长后减小,即为凸性函数。能够用三分法来求解

代码:

#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
using namespace std;
#define pi 3.141592653
double x,y,l,w;
double cal(double a)
{
double s=l*cos(a)+w*sin(a)-x;
double h=s*tan(a)+w*cos(a);
return h;
}
int main()
{
while(scanf("%lf %lf %lf %lf",&x,&y,&l,&w)!=EOF)
{
double left=0.0,right=pi/2;
double lm,rm;
while(fabs(right-left)>1e-6)
{
lm=(left*2.0+right)/3.0;
rm=(left+right*2.0)/3.0;
if(cal(lm)>cal(rm))
right=rm;
else left=lm;
}
if(cal(left)<=y)
printf("yes\n");
else printf("no\n");
}
return 0;
}

hdu 2348 Turn the corner(三分&amp;&amp;几何)(中等)的更多相关文章

  1. HDU 2438 Turn the corner(三分查找)

    托一个学弟的福,学了一下他的最简便三分写法,然后找了一道三分的题验证了下,AC了一题,写法确实方便,还是我太弱了,漫漫AC路!各路大神,以后你们有啥好的简便写法可以在博客下方留个言或私信我,谢谢了! ...

  2. hdu 2438 Turn the corner [ 三分 ]

    传送门 Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  3. Turn the corner (三分)

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

  4. hdu 2438 Turn the corner(几何+三分)

    Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...

  5. hdu 2438Turn the corner 三分

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  6. Turn the corner

    Problem Description Mr. West bought a new car! So he is travelling around the city. One day he comes ...

  7. HDU2438 Turn the corner【三分法】【数学几何】

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  8. HDU 4869 Turn the pokers(推理)

    HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...

  9. Turn the corner

    Turn the corner Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...

随机推荐

  1. PCL中分割方法的介绍(3)

    (3)上两篇介绍了关于欧几里德分割,条件分割,最小分割法等等还有之前就有用RANSAC法的分割方法,这一篇是关于区域生成的分割法, 区 域生长的基本 思想是: 将具有相似性的像素集合起来构成区域.首先 ...

  2. javascript显示年月日时间代码

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. MyBatis错误:Result Maps collection already contains value for novel.storage.mapper.NovelMapper.BaseResultMap

    今天在写项目的时候遇到一个问题如下: org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession. ...

  4. 最近迷上了GUI

    package windows; import java.awt.BorderLayout; import javax.swing.ButtonGroup; import javax.swing.JB ...

  5. selenium操作浏览器-窗口切换

    package seleniumLearn1; import java.util.Set; import java.util.concurrent.TimeUnit; import org.openq ...

  6. 性能优化系列四:Tomcat优化

    一.Tomcat工作原理 1. TCP的三次握手四次挥手 三次握手: 说明: 类比于A和B打电话: A对B说:你好,我是A,你能听到我说话吗? B对A说:嗯,我能听到你说话 A对B说:好,那我们开始聊 ...

  7. 因修改/etc/sudoers权限导致sudo和su不能使用的解决方法

    因为修改了/etc/sudoers以及相关权限,导致sudo无法使用,恰好Ubuntu的root密码没有设置,每次执行 su - 时.输入密码,提示:认证错误 . 解决方法: 1.重启ubuntu,启 ...

  8. win10专业版激活方法

    slmgr.vbs /upk 此时弹出窗口显未“已成功卸载了产品密钥”. slmgr /ipk W269N-WFGWX-YVC9B-4J6C9-T83GX 弹出窗口提示:“成功的安装了产品密钥”. s ...

  9. Spring核心框架体系结构(jar包引用分析)[转]

    很多人都在用spring开发java项目,普通添加lib目录拷贝jar包,或者创建maven项目时,配置maven依赖的时候并不能明确要配置哪些spring的jar,经常是胡乱添加一堆,编译或运行报错 ...

  10. Win7-64位安装TensorFlow-GPU

    1.查看电脑显卡 路径:计算机--属性--设备管理器-显示适配器 2.显卡(GPU)是否支持CUDN https://developer.nvidia.com/cuda-gpus 3.安装 1)CUD ...