2300: we share a wireless route (ferma point)

Source: Internet
Author: User
Tags acos
Document directory
  • Input
  • Output
  • Sample Input
  • Sample output
Result Time Limit Memory limit Run times AC times Judge
3 S 8192 K 143 52 Standard

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. ultraviolet. 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. obviusly, parhelic, codger and I are three vertex of a triangle (our rooms are not in a straight line ). we only got the lengt H of the three edges of the triangle and began to solve the problem. Can you do us a favor?

Input

There will be several test cases. each test case gives you three positive intergers A, B and C, represents the length of an edge respectively. it is guaranteed that a <= B <= C and they can compose of a triangle.

Output

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 ).

Sample Input

3 4 5
10 10 10
4 5 8

Sample output
6.766
17.321
9.000
/*
| Important points of a triangle
| Init: PNT [] has been sorted clockwise (or counterclockwise;
| Call: res = bcenter (PNT, N );
Set the three sides of a triangle to A, B, C, and assume a <= B <= C,
The area of the triangle can be calculated according to the Helen formula as follows:
S = SQRT (p * (p-a) * (p-B) * (p-C ));
P = (A + B + C)/2;
The following is the sum of the distance between the vertex and the three vertex A, B, and C of the triangle.

1. Fermat point (the sum of the distance between the vertex and the three vertex of the triangle is the smallest)
An interesting conclusion is that if the three inner angles of a triangle are less than 120 degrees, the points are connected.
The three angles formed by the three vertices are 120 degrees. If an inner angle of a triangle is greater than 120 degrees,
The vertex is the Fermat point.) The formula is as follows:
If an inner angle is greater than 120 degrees (this is assumed to be angle C), the distance is a + B.
If the three inner angles are less than 120 degrees, the distance is
SQRT (A * A + B * B + C * C + 4 * SQRT (3.0) * s)/2), where

2. Inner ---- intersection of the angular bisector
Make x = (a + B-c)/2, y = (a-B + C)/2,
Z = (-A + B + C)/2, H = s/P. The formula is
SQRT (x * x + H * h) + SQRT (y * Y + H * h) + SQRT (z * z + H * H)

3. Center of Gravity-the intersection of the midline. The calculation formula is as follows:
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. center-the point of the vertical line. The calculation formula is as follows:
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", & 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 );
} // Remember the formula! (Although I don't know how)
Printf ("%. 3lf/N", ANS );
}
Return 0;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.