HDU 2438 Turn the corner
阿新 • • 發佈:2019-02-02
#include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <queue> #include <vector> using namespace std; #define eps 1e-5 const double pi=acos(-1.0); double x,y,l,w; double Cal(double k) { return l*cos(k)+(w-x*cos(k))/sin(k); } double T_Find() { double l=0,r=pi/2,ll,rr; while(r-l>eps) { ll=l+(r-l)/3; rr=r-(r-l)/2; double Ans1=Cal(ll),Ans2=Cal(rr); if(Ans1<Ans2) l=ll; else r=rr; } return Cal(l); } int main() { while(scanf("%lf%lf%lf%lf",&x,&y,&l,&w)!=EOF) { double pd=T_Find(); if(pd<=y) printf("yes\n"); else printf("no\n"); } return 0; }