题目链接:Link
Solution
作为蒟蒻的我在CSDN上找了篇题解借鉴了一下 原文,我这篇题解算是对原题解的补充说明。
#include<cstdio>
#include<cmath>
const double pi=acos(-1.0);
double area(double a,double b,double c)
{//在知道三边的情况下用海伦公式求面积
double p=(a+b+c)/2.0;
return sqrt(p*(p-a)*(p-b)*(p-c));
}
double area2(double a,double B,double C)
{//角角边求面积
double A=pi-B-C;
double b=a*sin(B)/sin(A);//正弦定理的变形
double c=a*sin(C)/sin(A);
return area(a,b,c);
}
double area3(double a,double B,double C)
{
double A=pi-B-C;
double r=area2(a,B,C)/a*2.0;//根据面积求高(半径)
return r*r*A/2;
}
int kase;
double a,b,c,A,B,C,aa,bb,cc,sa,sb,sc;
double ha,hb,hc,s,t;
int main()
{
#ifdef local
freopen("pro.in","r",stdin);
#endif
while(scanf("%lf%lf%lf",&a,&b,&c)==3&&!(a==0&&b==0&&c==0))
{
A=acos((b*b+c*c-a*a)/(2.0*b*c));//余弦定理的变形
B=acos((a*a+c*c-b*b)/(2.0*a*c));
C=acos((a*a+b*b-c*c)/(2.0*a*b));
aa=(pi-A)/2;// ∠FAB ∠EAC
bb=(pi-B)/2;// ∠FBA ∠DBC
cc=(pi-C)/2;// ∠ACE ∠BCD
/*
由于同时和两直线相切,因此圆心连线为原直线的平分线,
因此可以用 ∠A、∠B、∠C算出∠FAB ∠EAC ∠FBA ∠DBC ∠ACE ∠BCD
注意单位为弧度
*/
sa=area2(a,bb,cc);
sb=area2(b,aa,cc);
sc=area2(c,aa,bb);//角角边求面积
s=area(a,b,c)+sa+sb+sc;
t=area3(a,bb,cc)+area3(b,aa,cc)+area3(c,aa,bb);
printf("Case %d: %.2lf %.2lf\n",++kase,s,t);
}
return 0;
}