
AC代码:
1 #include<cstdio>
2 #include<cmath>
3 #include<algorithm>
4 #include<iostream>
5 #include<cstring>
6 using namespace std;
7 typedef long long ll;
8 const double eps = 1e-8;
9 int sgn(double x)
10 {
11 if(fabs(x) < eps) return 0;
12 else return x < 0 ? -1 : 1;
13 }
14 int main()
15 {
16 double a, b ,c;
17 while(~scanf("%lf %lf %lf",&a,&b,&c))
18 {
19 if(a!=0 && b != 0 && c != 0 && sgn(a + b - c) > 0&& sgn( a + c - b ) > 0 &&sgn( b + c - a) > 0)
20 {
21 double p =a + b + c;
22 double Elem1 = p -2*a;
23 double Elem2 = p -2*b;
24 double Elem3 = p -2*c;
25 double S=sqrt(p *Elem1*Elem2*Elem3);
26 S/=3;
27 printf("%.3f\n",S);
28 }
29 else
30 printf("-1.000\n");
31 }
32 return 0;
33 }