Parhelic, codger and I are good friends. As we know, the educational net can not access to foreign websites. As a result, we can't go to acm.uva.es to solve problems. So we decided to find a way to share a CNC net. We three lived in different rooms, but luckily enough, we each had a laptop computer with wireless module. So we bought a wireless route. After reading the introduction of the route, we knew that the position to set the route is quite a problem.
There is a distance limit D of the wireless route. PR, CR, LR represents the distance from Parhelic, Codger, I to the Route respectively. PR+CR+LR cannot be bigger than D, or the signal will be quite unstable. So we had to calculate the minimum possible sum of PR, CR and LR. Obviously, Parhelic, codger and I are three vertex of a triangle(our rooms are not in a straight line). We only got the length of the three edges of the triangle and began to solve the problem. Can you do us a favor?
Find out the best place for the route and output the minimum sum of PR, CR and LR in one line per test case(accurate to 0.001).
1. 费马点(该点到三角形三个顶点的距离之和最小) 有个有趣的结论:若三角形的三个内角均小于120度,那么该点连接三个顶点形成的三个角均为120度;若三角形存在一个内角大于120度,则该顶点就是费马点)计算公式如下:若有一个内角大于120度(这里假设为角C),则距离为a + b若三个内角均小于120度,则距离为sqrt((a * a + b * b + c * c + 4 * sqrt(3.0) * s) / 2),其中
2. 内心----角平分线的交点 令x = (a + b - c) / 2, y = (a - b + c) / 2, z = (-a + b + c) / 2, h = s / p. 计算公式为sqrt(x*x + h*h) + sqrt(y*y + h*h) + sqrt(z * z + h * h)
3. 重心----中线的交点, 计算公式如下: 2.0 / 3 * (sqrt((2 * (a * a + b * b) - c * c) / 4) + sqrt((2 * (a * a + c * c) - b * b) / 4) + sqrt((2 * (b * b + c * c) - a * a) / 4))
4. 垂心----垂线的交点, 计算公式如下: 3 * (c / 2 / sqrt(1 - cosC * cosC))
*/ #include <cstdio>#include <iostream>#include <cmath>//#include <>using namespace std;const double pi=acos(-1.);double s (double a,double b,double c){ double p=(a+b+c)/2; return sqrt(p*(p-a)*(p-b)*(p-c));} int main (){ double a,b,c; while (scanf("%lf%lf%lf",&a,&b,&c)!=EOF) { double tmp=(a*a+b*b-c*c)/(2*a*b),ans; tmp=acos(tmp); if(tmp>=pi*2/3) { ans=a+b;// } else { ans=sqrt((a * a + b * b + c * c + 4 * sqrt(3.0) * s(a,b,c)) / 2); }//公式 要记住!(虽然不知道怎么来的) printf("%.3lf/n",ans); } return 0;}