Turn the corner

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

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
 题目大意:有一个转角,给你它的x,y和汽车的长l和宽d,问你它能否成功转弯。
思路分析:现象很常见,但我们很少去思考它能不能转弯,对于这种题目,一定要
将其转化为代数运算,建立合适的坐标系是比较常用的想法,
图像可以参考这个博客http://blog.csdn.net/u013761036/article/details/24588987
这样做是假设汽车贴着外边走,判断最宽的地方是否<Y,感觉假设贴着内边走也是能够做
出来的,至于为什么采用三分法,稍微感觉一下趋
势就可以,很显然最宽的时候是在转动的过程中,因此在【0,pi/2]之间二分即可
代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cmath>
using namespace std;
double x,y,l,w;
const double pi=acos(-1.0);
const double eps=1e-7;
double cal(double a)
{
   double k=x-l*sin(a)-w/cos(a);
   return -k/tan(a);
}
int main()
{
    while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF)
    {
       double l=0.0,r=pi/2;
       if(x<=w|| y<=w) {printf("no\n");continue;}
       while(l+eps<=r)
       {
           double mid=(l+r)/2.0;
           double mmid=(mid+r)/2.0;
           if(cal(mid)<=cal(mmid)) l=mid;
           else r=mmid;
       }
       if(cal(r)<y) printf("yes\n");
       else printf("no\n");
    }
    return 0;
}
刚始那句特判必不可少,不太懂为什么,因为它弱wa了三发,
求高人指教。

hdu 2438Turn the corner 三分的更多相关文章

  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. hdu 2348 Turn the corner(三分&amp;&amp;几何)(中等)

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

  4. nyoj 1029/hdu 3714 Error Curves 三分

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714 懂了三分思想和F(x)函数的单调性质,这题也就是水题了 #include "stdio ...

  5. hdu 3714 Error Curves(三分)

    http://acm.hdu.edu.cn/showproblem.php?pid=3714 [题意]: 题目意思看了很久很久,简单地说就是给你n个二次函数,定义域为[0,1000], 求x在定义域中 ...

  6. hdu Turn the corner

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

  7. Turn the corner (三分)

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

  8. HDU 2298 Toxophily(公式/三分+二分)

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

  9. HDU题解索引

    HDU 1000 A + B Problem  I/O HDU 1001 Sum Problem  数学 HDU 1002 A + B Problem II  高精度加法 HDU 1003 Maxsu ...

随机推荐

  1. Github提交代码及分支管理

    #提交代码cd <Cat>git initgit add .git statusgit commit -m "注释"git remote add origin < ...

  2. Mysql中的 的 Cascade ,NO ACTION ,Restrict ,SET NULL

    转载自:http://blog.163.com/inflexible_simple/blog/static/1676946842011616102543931/ 外键约束对子表的含义:    如果在父 ...

  3. 使用 c# 调用进程相关开发

    最近在维护公司的以前项目中发现,使用到了进程相关知识.现在将此总结,以备后面查看复习. 一.进程查看器     程序在运行的时候,操作系统就会为其分配一个进程.那么进程到底是什么东西呢? 实际上,进程 ...

  4. .net转php laraval框架学习系列(四) 项目实战---View

    laravel的参考文档中view的讲解有些简单. 在实际项目开发中view的灵活性其实是非常大. 首先来看看laravel中的布局页 和asp.net mvc中有什么不同 <!DOCTYPE ...

  5. ie7 不兼容overflow:hidden;

    用overflow:hidden; 隐藏不需要显示的数据,在IE6\IE8都显示正常,但是在ie7中就是不起作用,万恶的IE7啊.后来加了一句position:relative; 好了... stat ...

  6. 安卓 eclipse项目创建

    一. 创建项目工程 1.  点击 file -> new -> Android Application project -> 2.  创建工程项目名字   自己命名 (注: 不要出现 ...

  7. 编译内核时出错:/bin/sh: 1: lzop: not found

    http://www.deyisupport.com/question_answer/dsp_arm/sitara_arm/f/25/t/71477.aspx 在上面链接中,发现时缺少了 lzop 工 ...

  8. Codeforces 455B A Lot of Games

    http://codeforces.com/contest/455/problem/B 题目大意: 给出n个字符串,进行k次游戏,每次游戏输家下次作为先手,游戏规则为每次放一个字母,导致当前构造的字符 ...

  9. 【Xamarin开发IOS-IOS生命周期】

    iOS的应用程序的生命周期,还有程序是运行在前台还是后台,应用程序各个状态的变换,这些对于开发者来说都是很重要的. iOS系统的资源是有限的,应用程序在前台和在后台的状态是不一样的.在后台时,程序会受 ...

  10. mysql出现错误“ Every derived table must have its own alias”

    Every derived table must have its own alias 这句话的意思是说每个派生出来的表都必须有一个自己的别名 一般在多表查询时,会出现此错误. 因为,进行嵌套查询的时 ...