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

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
 
 
 
分析:这个题就是看车子是否能通过这个转角!
 
 
 
如图分析,如果h最大的时候还是小于y的,那么车一定能通过!
即变相的求函数h=l*sin(a)-x*tan(a)+d/cos(a)的最大值,显然用三分法!
 #include<stdio.h>
#include<math.h>
#define PI 3.1415926535
double l,d,x,y;
double hs(double p)
{
double w;
w=l*sin(p)-x*tan(p)+d/cos(p);//函数,计算h
return w;
}
int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
double a=,b=PI/,mid,midmid;
do
{
//mid=(b-a)/3+a;
//midmid=(b-a)*2/3+a;
mid=(a+b)/;
midmid=(mid+b)/;
if(hs(mid)>hs(midmid))
b=midmid;
else
a=mid;
}while(b-a>1e-);
if(hs(mid)<y)
printf("yes\n");
else
printf("no\n");
}
return ;
}

Turn the corner--hdu2438(3分法)的更多相关文章

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

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

  2. Turn the corner (三分)

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

  3. 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. HDU 2438 Turn the corner(三分查找)

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

  6. 将n个东西分成n1,n2,n3,n4,....nr 共 r组分给r个人有多少种分法。

    (n!/(n1! *n2! *n3!..nr!) )   * r!/( 同数量组A的数量! 同数量组B的数量!....) 比方20个东西分成2,2,,2,2   3,3,3,3 8组分给8个人有多少种 ...

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

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

  8. hdu 2438 Turn the corner [ 三分 ]

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

  9. CSP-J2019 把8个同样的球放在同样的5个袋子里,允许有的袋子空着不放,问共有多少种不同的分法?

    把8个同样的球放在同样的5个袋子里,允许有的袋子空着不放,问共有多少种不同的分法? 提示:如果8个球都放在一个袋子里,无论是放哪个袋子,都只算同一种分法. 解析: 把问题合成,先思索5个袋子都不空的状 ...

随机推荐

  1. popup

    http://vast-engineering.github.com/jquery-popup-overlay/ http://photoswipe.com/

  2. 磁盘管理二-LVM相关内容

    1.基本概念 LVM:logical volume manager 逻辑卷管理器 LVM构成:物理卷PV,卷组VG(PE物理区域,最小存储单元),逻辑卷LV(LE逻辑区域,最小存储单元) 三者如下图所 ...

  3. 阿里巴巴集团2013实习生招聘技术类笔试题(B)

    一.单向选择题 1.在常用的网络协议中,___B__是面向连接的.有重传功能的协议. A. IP B. TCP C. UDP D. DXP 2.500张骨牌整齐地排成一行,按顺序编号为1.2.3... ...

  4. Prime Path(POJ 3126 BFS)

    Prime Path Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15325   Accepted: 8634 Descr ...

  5. POJ 1020 Anniversary Cake(DFS)

    Anniversary Cake Time Limit: 1000MSMemory Limit: 10000KB64bit IO Format: %I64d & %I64u Submit St ...

  6. 1007 Numerical Summation of a Series

    简单入门题.按照题目给的指导编程,算多少数要理解题意. #include <stdio.h> int main(){ int k,ssx; double x,psix; ;ssx<= ...

  7. [TYVJ] P1030 乳草的入侵

    乳草的入侵 背景 Background USACO OCT09 6TH   描述 Description Farmer John一直努力让他的草地充满鲜美多汁的而又健康的牧草.可惜天不从人愿,他在植物 ...

  8. 【转】 linux内核移植和驱动添加(三)

    原文网址:http://blog.chinaunix.net/uid-29589379-id-4708909.html 原文地址:linux内核移植和驱动添加(三) 作者:genehang 四,LED ...

  9. java List与数组互转

    数组转List:String[] arr = new String[] {"str1", "str2"};List<String> list = A ...

  10. Remove Duplicates from Sorted List II 解答

    Question Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only dist ...