## UVA 11731 Ex-circles（旁切圆）

2019年02月12日 ⁄ 综合 ⁄ 共 1137字 ⁄ 字号 评论关闭

```#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>

using namespace std;

const double pi = acos(-1.0);

double anga, angb, angc;
double angd, ange, angf;
double a, b, c;
double AE, AF, BD, BF, CD, CE;
double DE, EF, FD;
double dsin, esin, fsin;
double rd, re, rf;

double GetArea(double a, double b, double c)
{
double p = (a + b + c) / 2.0;
return sqrt(p * (p - a) * (p - b) * (p - c));
}

double GetR(double a, double b, double c)
{
return (2.0 * GetArea(a, b, c) / c);
}

void Calc()
{
anga = acos((b * b + c * c - a * a) / (2.0 * b * c));
angb = acos((a * a + c * c - b * b) / (2.0 * a * c));
angc = pi - anga - angb;
angd = (pi - anga) / 2.0;
ange = (pi - angb) / 2.0;
angf = pi - angd - ange;
dsin = sin(angd); esin = sin(ange); fsin = sin(angf);
AF = c / fsin * esin; AE = b / esin * fsin;
BD = a / dsin * fsin; BF = c / fsin * dsin;
CD = a / dsin * esin; CE = b / esin * dsin;
DE = CD + CE; EF = AE + AF; FD = BD + BF;
printf("%.2lf ", GetArea(DE, EF, FD));
rd = GetR(BD, CD, a);
re = GetR(AE, CE, b);
rf = GetR(AF, BF, c);
printf("%.2lf\n", (angd * rd * rd + ange * re * re + angf * rf *rf) / 2.0);
}

int main()
{
int cas = 1;
while(scanf("%lf%lf%lf", &a, &b, &c) && (a || b || c))
{
printf("Case %d: ", cas++);
Calc();
}
return 0;
}
```