传送门

Turn the corner

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2081    Accepted Submission(s): 787

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
Source
2008 Asia Harbin Regional Contest Online
Recommend
gaojie   |   We have carefully selected several similar problems for you:  2444 2441 2442 2443 2440
题解转一发:
http://www.cnblogs.com/wally/archive/2013/05/14/3077383.html

网上大牛思路:

可以根据边界,汽车已经转弯,设水平方向为x轴,垂直方向为y轴。

则汽车的内边界(靠近里面的边界)的直线方程式f(x)为:y=x*tan(a)+l*sin(a)+d/cos(a).其中a是汽车与x轴的夹角

当y=X时,求解出的-x即为汽车的内边界到y轴的距离h,若h小于Y即可转弯,若大于Y就不能转弯。
所以只需要利用方程式,求-x的最大值,即可判断能否通过。
由于f(x)是凸函数(随着x的增大y先增大后减小),所以,需要借助三分求解。

图示:

第一道三分求极值题啊!!!

Run ID Submit Time Judge Status Pro.ID Exe.Time Exe.Memory Code Len. Language Author
13216500 2015-03-23 09:01:02 Accepted 2438 0MS 1688K 946 B G++ czy
 1 #include <cstdio>
 2 #include <cmath>
 3
 4 using namespace std;
 5
 6 const double mi = 1e-7;
 7 const double eps = 1e-9;
 8 const double pi = 4.0 * atan(1.0);
 9
10 double x,y,l,d;
11
12 double cal(double a)
13 {
14     return (-x + l * sin(a) + d / cos(a)) / tan(a) ;
15 }
16
17 int main()
18 {
19     while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
20     {
21         if(d>y || d>x){
22             printf("no\n");continue;
23         }
24         double low=0,high = pi / 2,mid,mmid;
25         double te1,te2;
26         while(high - low > mi)
27         {
28             mid = (low + high) / 2;
29             mmid = (low + mid) / 2;
30             te1 = cal(mid);
31             te2 = cal(mmid);
32             if(te1 > te2){
33                 low = mmid;
34             }
35             else{
36                 high = mid;
37             }
38         }
39         te1 = cal(low);
40         if(te1 < y){
41             printf("yes\n");
42         }
43         else{
44             printf("no\n");
45         }
46     }
47 }

转载于:https://www.cnblogs.com/njczy2010/p/4358891.html

hdu 2438 Turn the corner [ 三分 ]相关推荐

  1. HDU - 2438 Turn the corner(三分)

    题目链接:点击查看 题目大意:直接上图: 给出四个参数:x,y,l,d,分别如图所示,问汽车能否拐弯成功 题目分析:在这里借个图: 让车辆能转过去的最优解肯定是左侧贴着直角点,右侧后端的顶点与右墙接触 ...

  2. hdu Turn the corner

    这题是道三分的题,首先要分析满足条件的情况,这个就是平面几何的功夫了.要想车子能够转弯成功,最上面那个点到水平线的距离要小于等于y.这里h和s的公式就是利用平面几何的知识求出来的:s=l*cos(a) ...

  3. HDU 4869 Turn the pokers(思维+组合公式+高速幂)

    Turn the pokers 大意:给出n次操作,给出m个扑克.然后给出n个操作的个数a[i],每一个a[i]代表能够翻的扑克的个数,求最后可能出现的扑克的组合情况. Hint Sample Inp ...

  4. HDU 4869 Turn the pokers(思维+组合公式+快速幂)

    Turn the pokers 大意:给出n次操作,给出m个扑克,然后给出n个操作的个数a[i],每个a[i]代表可以翻的扑克的个数,求最后可能出现的扑克的组合情况. Hint Sample Inpu ...

  5. 三分法与二分法的区别和三分法总结

    三分法介绍 在区间内用两个mid将区间分成三份,这样的查找算法称为三分查找,也就是三分法,三分法常用于求解单峰函数的最值.          还有一种理解,即在二分查找的基础上,在左区间或者右区间上再 ...

  6. 【专题】三分法和牛顿迭代法总结

    下面总结两种迭代方法:三分法和牛顿迭代 1.三分法 二分法作为分治中最常见的方法,适用于单调函数,逼近求解某点的值.但当函数是凸性函数时,二分法就无法适用,这时三分法就可以大显身手. 如下凸函数: 类 ...

  7. 考研英语二真题文章重点单词

    2019 #完形填空 stay aware of 保持--的意识:随时留意-- fluctuation n. 起伏,波动 as for 至于,关于 shift from 从--转移 generally ...

  8. 坚持不懈,直到成功-I will persist. I will win.

    I will persist until I succeed. 坚持不懈.直到成功. In the Orient young bulls are tested for the fight arena ...

  9. cadence SPB17.4 capture and cis 全部错误消息列表

    前言 在整理层次原理图,中间遇到好多编译警告和错误. 刚将封装之外的错误和警告都消掉了. 再想,官方对于错误消息有没有一个汇总和解释呢? 在本地帮助文件中找到了, capture的所有错误消息说明文件 ...

最新文章

  1. 985大学的高材生只会写代码片段,丢人吗?
  2. URL/URI/URN的认识
  3. Eclipse使用技巧收集
  4. poker java idea_JavaBasic学习笔记
  5. Order Proposals in the Past
  6. linux报文高速捕获技术对比--napi/libpcap/afpacket/pfring/dpdk/xdp
  7. 安防无战事:一场 10213 亿元的误会
  8. Linux系统如何创建和挂载XFS文件系统
  9. eclipse查看git地址_40个适用于Linux管理员和开发人员的git命令(上)
  10. poi合并docx文档
  11. 在win32上用wgl折腾OpenGL 3.3等高版本OpenGL
  12. .NET Core 对象到字节数组的序列化和反序列化
  13. 级数_2:常数项级数的审敛法
  14. PySpark | Spark3新特性 | Spark核心概念
  15. Gps测量两点之间的距离
  16. 申请邓白氏编码的流程
  17. Unreal - Environment Query System(EQS)
  18. Java设计模式-模板模式
  19. 文本分割之垂直投影法基于OpenCV(python)的实现
  20. PDCCH-based WUS signal

热门文章

  1. MFC UI库知多少
  2. windows API 菜鸟学习之路(四)
  3. navicat工具查看MySQL数据库_表占用容量_占用空间是多少MB---Linux工作笔记048
  4. C++开发环境搭建_需要学习的内容介绍_写第一个C++程序---C++语言工作笔记008
  5. 数据库工作笔记002---新建mysql数据库的时候_对字符集和排序规则的选择
  6. Netty工作笔记0051---Netty核心模块2
  7. SpringCloud学习笔记014---可以使用json对rabbitmq进行封装,方便数据传输
  8. 在ubuntu里烧win10安装盘
  9. Install Rouge and Pyrouge for python 2.7 (conda virtual env) on Linux 64
  10. NLP之路-继续书本上的实验