# SGU 151 - Construct a triangle

## Description

Find coordinates of any $\triangle ABC$ if it is know that $|AB|=c$, $|AC|=b$, $|AM|=m$, $AM$ is a median of triangle.

## Input

There are three real numbers in input: $c$, $b$, $m$ ($0<c, b, m\leq 10^3$) separated by a space. Length of the fractional part of each number is not greater than 2 digits.

## Output

If solution exists, write three lines. Write coordinates of point $A$ to first line, coordinates of $B$ to second line and coordinates of $C$ to third line. Separate numbers by a space; absolute value of each coordinate must not exceed $10^4$. Write numbers with 5 digits after decimal point. If there is no solution, write “Mission impossible”.

## Sample Input

 1  5 5 3 

## Sample Output

 1 2 3  0.00000 3.00000 -4.00000 0.00000 4.00000 0.00000 

## Solution

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32  #include #include #include using namespace std; int Check(double x); int main() { double c, b, m; while(cin >> c >> b >> m) { double x = (4 * m * m - b * b - c * c) / (2 * c), y = b * b - x * x; if(Check(y) >= 0) { if(Check(x) == 0) { x = 0; } if(Check(y) == 0) { y = 0; } cout << fixed << setprecision(5) << 0.0 << " " << 0.0 << endl; cout << fixed << setprecision(5) << c << " " << 0.0 << endl; cout << fixed << setprecision(5) << x << " " << sqrt(y) << endl; } else { cout << "Mission impossible" << endl; } } return 0; } int Check(double x) { if(fabs(x) < 1E-9) { return 0; } else { return x > 0 ? 1 : -1; } }