Problem K
Trials and Triangulations
More math? You got it. That’s what computers do, they compute.
Heron’s formula gives the area, $A$, of a triangle with sides $a$, $b$, and $c$ as $A = \sqrt{s(s-a)(s-b)(s-c)}$ where $s = (a+b+c)/2$.
Write a program that prompts for three integers, $a$, $b$, and $c$, denoting the lengths of the sides of a triangle. Calculate the area, and print the result.
Hint: You can use the sqrt function in the math module.
Input
Input consists of three lines. The first line consists of one integer $a$. The second line consists of one integer $b$. The third line consists of one integer $c$. It is guaranteed that $1 \leq a, b, c \leq 100$ and that the values can form a triangle.
Output
Output one line with one floating point number $A$, the area of the triangle. The output number should have an absolute or relative error of at most $10^{-9}$.
Sample Input 1 | Sample Output 1 |
---|---|
1 1 1 |
0.433012701892219 |
Sample Input 2 | Sample Output 2 |
---|---|
1 2 3 |
0.000000000000000 |
Sample Input 3 | Sample Output 3 |
---|---|
2 2 3 |
1.984313483298443 |
Sample Input 4 | Sample Output 4 |
---|---|
12 9 19 |
41.952353926806062 |
Sample Input 5 | Sample Output 5 |
---|---|
5 4 3 |
6.000000000000000 |
Sample Input 6 | Sample Output 6 |
---|---|
5 12 13 |
30.000000000000000 |