Solution : 二分、二分a的长度,然后根据l,h计算出角平分线的长度,判断即可。。。
Code:
// SGU 244 Height Bisector and Median
// Solution : Math Calculate
//
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
using namespace std;
#define FOR(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define DOR(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define oo 1e6
#define nMax 100000
#define pb push_back
#define dbg(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define F first
#define S second
#define bug puts("OOOOh.....");
#define zero(x) (((x)>0?(x):-(x))<eps)
#define LL long long
#define DB double
#define sf scanf
#define pf printf
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// Solution Part:
//
double const eps = 1e-9;
int dcmp(double x) {
if(x>-eps && x<eps) return 0;
return x > 0 ? 1 : -1;
}
struct P{
double x,y;
P() {};
P(double x,double y):x(x),y(y){};
P operator * (double k) { return P(x*k,y*k); }
P operator - (P u) { return P(x-u.x,y-u.y); }
P operator + (P u) { return P(x+u.x,y+u.y); }
double len() { return sqrt(x*x+y*y); }
void out() { pf("%.7lf %.7lf\n",x+1e-10,y+1e-10); }
};
P A,B,C,D;
double AB,AC,AD;
double h,r,l;
double cal(double a) {
B = P(0,0),
C = P(a,0);
double alfa = asin(h*1.0/r);
A.x = a/2.0 + sqrt(r*r-h*h);
A.y = h;
AB = (A-B).len();
AC = (A-C).len();
double t = (AB)/(AB+AC);
D = (C-B)*t + B;
AD=(A-D).len();
return AD;
}
int NoSolution(){
int d1 = dcmp(l-h),
d2 = dcmp(r-l);
if(d1 < 0 || d2 < 0) return 1;
if(d1 == 0 && d2 != 0 ) return 1;
if(d1 != 0 && d2 == 0 ) return 1;
return 0;
}
int main () {
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
cin >> h >> l >> r;
double ll = 0 , rr = 1e5;
double mid,L;
if(NoSolution()) {
pf("NO\n");
return 0;
}
while(rr-ll >= 1e-9) {
mid = (ll+rr)/2.0;
L = cal(mid) ;
if(dcmp(L-l)==0) break;
if(dcmp(L-l)>0) ll = mid;
else rr = mid;
}
ll = (ll+rr)/2.0;
pf("YES\n");
cal(ll);
A.out();
B.out();
C.out();
return 0;
}