SGU 244. Height, Bisector and Median

57 篇文章 0 订阅
29 篇文章 0 订阅

Link To The Problem


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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值