三角形三边边长a,b,c,则p=(a+b+c)/2;s=sqrt(p*(p-a)*(p-b)*(p-c));
1 #include <cstdio>
2 #include <cstring>
3 #include <cmath>
4 const int Pi=4*acos(-1.0);
5 double r1,r2,r3;
6 double a,b,c;
7 double getarea(double a,double b,double c)
8 {
9 double p=a+b+c;
10 p/=2;
11 return sqrt(p*(p-a)*(p-b)*(p-c));
12 }
13 double gettarea(double a,double b,double c,double r)
14 {
15 double t=(a*a+b*b-c*c)/(2*a*b);
16 t=acos(t);
17 return t/2*r*r;
18 }
19 int main()
20 {
21 int T;
22 scanf("%d",&T);
23 for (int t=1;t<=T;t++)
24 {
25 scanf("%lf%lf%lf",&r1,&r2,&r3);
26 a=r1+r3;
27 b=r1+r2;
28 c=r2+r3;
29 double ans=getarea(a,b,c)-gettarea(a,b,c,r1)-gettarea(b,c,a,r2)-gettarea(a,c,b,r3);
30 printf("Case %d: %.9lf\n",t,ans);
31 }
32 return 0;
33 }
时间: 2024-11-05 21:28:00