传送门

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
 
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
 #include <cstdio>
#include <cmath> using namespace std; const double mi = 1e-;
const double eps = 1e-;
const double pi = 4.0 * atan(1.0); double x,y,l,d; double cal(double a)
{
return (-x + l * sin(a) + d / cos(a)) / tan(a) ;
} int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
if(d>y || d>x){
printf("no\n");continue;
}
double low=,high = pi / ,mid,mmid;
double te1,te2;
while(high - low > mi)
{
mid = (low + high) / ;
mmid = (low + mid) / ;
te1 = cal(mid);
te2 = cal(mmid);
if(te1 > te2){
low = mmid;
}
else{
high = mid;
}
}
te1 = cal(low);
if(te1 < y){
printf("yes\n");
}
else{
printf("no\n");
}
}
}

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

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

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

  2. hdu 2348 Turn the corner(三分&amp;&amp;几何)(中等)

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

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

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

  4. Turn the corner (三分)

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

  5. codeforces 782B The Meeting Place Cannot Be Changed+hdu 4355+hdu 2438 (三分)

                                                                   B. The Meeting Place Cannot Be Change ...

  6. hdu 2438Turn the corner 三分

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

  7. Turn the corner

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

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

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

  9. HDU 4869 Turn the pokers(推理)

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

随机推荐

  1. slimScroll的应用(一)

    本类文章依旧是针对初学者来说的,希望大家看到后觉得有用的能给个赞~~ 什么是slimScroll? 一.官网介绍: slimScroll is a small (4.6KB) jQuery plugi ...

  2. P3371 【模板】单源最短路径

    题目描述 如题,给出一个有向图,请输出从某一点出发到所有点的最短路径长度. 输入输出格式 输入格式: 第一行包含三个整数N.M.S,分别表示点的个数.有向边的个数.出发点的编号. 接下来M行每行包含三 ...

  3. 架包Error inflating class错误

    当引用架包后,出现Error inflating class错误时通常要检测架包是否正确引用: 1.首先将你所需要的架包拷贝到工程目录下: 2.右击工程,选择Build Path-->confi ...

  4. 不能说的hidden

    不能说的hidden 时光跑跑...路在脚下...晨光依在...----Vashon 1.所谓"时尚",本质上就是自己看不见自己的样子.好比我们在地球上,却感觉不到地球在动. 2. ...

  5. 编译安装LAMP之php(fpm模块)

    一,准备工作实验平台为CentOS6.6,先下载所需的安装包,我使用的是php-5.4.26.tar.gz,下载地址 http://mirrors.sohu.com/php/ 编译安装的目录:/usr ...

  6. Angular和SAP C4C的事件处理队列

    Angular 我们在Angular框架的代码里能看到一个名为processQueue的函数: 这个函数是通过$scope.$apply启动的: 核心代码位于一个for循环里,循环体是一个存储异步处理 ...

  7. 屏幕卫士模式系统APP开发

    利用php的socket编程来直接给接口发送数据来模拟post的操作,(黎灿:I8O..2853..296O 可电可V)线上线下和物流结合在一起,才会产生新零售. 2016年阿里云栖大会上,阿里巴巴马 ...

  8. 【传智播客】Libevent学习笔记(二):创建event_base

    目录 00. 目录 01. 简介 02. 创建默认的event_base 03. 创建复杂的event_base 3.1 event_config_new函数 3.2 event_base_new_w ...

  9. Node.js 创建server服务器

    var http=require('http'); //引入http模块 var server=http.createServer(function(req,res){  //创建一个server r ...

  10. Function()构造函数与函数直接量

    Function()构造函数与函数直接量 制作人:全心全意 在JavaScript中,除了可使用基本的function语句定义函数之外,还可以使用另外两种方式来定义,即使用Function()构造函数 ...