HDU2438 数学+三分

Turn the corner

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

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?
HDU2438 数学+三分

 
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
代码:
HDU2438 数学+三分
 //三分,左分因为最值在左边。
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double x,y,l,d;
double F(double m)
{
return (x*sqrt(l*l-m*m)-m*y+m*sqrt(l*l-m*m))/l;
}
int main()
{
while(scanf("%lf%lf%lf%lf",&x,&y,&l,&d)!=EOF)
{
double lef=-1.0*l,rig=0.0,mid,midmid;
while(rig-lef>0.00000001)
{
mid=(lef+rig)/;
midmid=(mid+lef)/;
double tem1=F(mid);
double tem2=F(midmid);
if(tem1<=tem2) lef=midmid;
else rig=mid;
}
if(d<=min(F(mid),F(midmid)))
printf("yes\n");
else printf("no\n");
}
return ;
}
 
上一篇:Python并发编程04 /多线程、生产消费者模型、线程进程对比、线程的方法、线程join、守护线程、线程互斥锁


下一篇:三分之一的程序猿之社交类app踩过的那些坑