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. python计算机视觉2:图像边缘检测

    我是一名初学者,如果你发现文中有错误,请留言告诉我,谢谢 如果需要检测到图像里面的边缘,首先我们需要知道边缘处具有什么特征. 对于一幅灰度图像来说,边缘两边的灰度值肯定不相同,这样我们才能分辨出哪里是 ...

  2. 树上战争(HDU 2545 并查集求解点到根节点长度)

    树上战争 Time Limit: 10000/4000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submi ...

  3. 无法添加sql server ER图

    Database diagram support objects cannot be installed because this database does not have a valid own ...

  4. jprofiler安装和配置

    转:http://www.cnblogs.com/adolfmc/archive/2013/06/09/3129358.html 注意:安装前先用rpm -q jprofiler查询linux上是否已 ...

  5. UESTC_男神的约会 2015 UESTC Training for Dynamic Programming<Problem J>

    J - 男神的约会 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit ...

  6. Repeated DNA Sequences 解答

    Question All DNA is composed of a series of nucleotides abbreviated as A, C, G, and T, for example: ...

  7. zoj3433(贪心+优先队列)

    Gu Jian Qi Tan Time Limit: 2 Seconds      Memory Limit: 65536 KB Gu Jian Qi Tan is a very hot Chines ...

  8. openstack vm image

    1,openstack 基于iso生成镜像

  9. MAC 下cocos2d-x lua 使用dragonbones的方法

    项目使用db,网上查了半天全是vs和android的流程,没查到有mac的.这里记录一下. quick-cocos-x下的使用方法: a. 将dragonbones(放入ucocos2d_libs中) ...

  10. android ANR 案例分析

    案例1:关键词:ContentResolver in AsyncTask onPostExecute, high iowait Process:com.android.email Activity:c ...