uva 11731 - Ex-circles(几何)

942 篇文章 2 订阅
99 篇文章 0 订阅

题目链接:uva 11731 - Ex-circles


#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
const double pi = 4 * atan(1.0);

int A, B, C;

double getAngle(double a, double b, double c) {
	double tmp = (a * a + b * b - c * c) / (2 * a * b);
	return acos(tmp);
}

double getArea(double a, double b, double c) {
	double s =(a + b + c) / 2;
	return sqrt(s * (s - a) * (s - b) * (s - c));
}

int main () {
	int cas = 1;
	while (scanf("%d%d%d", &A, &B, &C) == 3) {
		if (A == 0 || B == 0 || C == 0)
			break;
		double cornerA = getAngle(B, C, A);
		double cornerB = getAngle(A, C, B);
		double cornerC = getAngle(A, B, C);

		double FAB = (pi - cornerA) / 2;
		double FBA = (pi - cornerB) / 2;
		double cornerF = pi - FAB - FBA;

		double EAC = (pi - cornerA) / 2;
		double ECA = (pi - cornerC) / 2;
		double cornerE = pi - EAC - ECA;

		double DBC = (pi - cornerB) / 2;
		double DCB = (pi - cornerC) / 2;
		double cornerD = pi - DBC - DCB;

		double Sabc = getArea(A, B, C);
		double Sabf = getArea(C, C / sin(cornerF) * sin(FAB), C / sin(cornerF) * sin(FBA));
		double Sace = getArea(B, B / sin(cornerE) * sin(EAC), B / sin(cornerE) * sin(ECA));
		double Sbcd = getArea(A, A / sin(cornerD) * sin(DBC), A / sin(cornerD) * sin(DCB));
		double ans1 = Sabc + Sabf + Sace + Sbcd;

		double ans2 = 0;
		double Rf = Sabf * 2 / C;
		ans2 += Rf * Rf * cornerF;
		double Re = Sace * 2 / B;
		ans2 += Re * Re * cornerE;
		double Rd = Sbcd * 2 / A;
		ans2 += Rd * Rd * cornerD;

		printf("Case %d: %.2lf %.2lf\n", cas++, ans1, ans2 / 2);
	}
	return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值