p151.ans1
======================
0.00000 3.00000
-4.00000 0.00000
4.00000 0.00000

=================
p151.cpp
======================
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

double c, b, m;

void read() { cin >> c >> b >> m; }

void solve() {
    // The median length satisfies m^2 = (2b^2 + 2c^2 - a^2) / 4, so the third
    // side is a = sqrt(2b^2 + 2c^2 - 4m^2); if that radicand is negative or
    // the three sides a, b, c violate the triangle inequality there is no
    // triangle. Otherwise we place A at the origin and B at (c, 0) along the
    // x-axis. With the law of cosines for the angle at A, cos = (b^2 + c^2 -
    // a^2)/(2bc), point C lies at (b*cos, b*sin), giving a valid placement.

    double inner_val = 2 * b * b + 2 * c * c - 4 * m * m;
    if(inner_val < 0) {
        cout << "Mission impossible\n";
        return;
    }

    double a = sqrt(inner_val);
    if(a > b + c || b > a + c || c > a + b) {
        cout << "Mission impossible\n";
        return;
    }

    double cos_c = (b * b + c * c - a * a) / (2 * b * c);

    double bx = c, by = 0;
    double cx = b * cos_c;
    double cy = b * sqrt(1 - cos_c * cos_c);

    cout << fixed << setprecision(6);
    cout << 0.0 << ' ' << 0.0 << '\n';
    cout << bx << ' ' << by << '\n';
    cout << cx << ' ' << cy << '\n';
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}

=================
p151.in1
======================
5 5 3

=================
p151.py
======================
import math


def find_triangle_coordinates(b, c, m):
    # m^2 = 1/4 (2b^2 + 2c^2 - a^2)

    inner_val = 2 * b**2 + 2 * c**2 - 4 * m**2
    if inner_val < 0:
        return None

    a = math.sqrt(inner_val)
    if a > b + c or b > a + c or c > a + b:
        return None

    # Use cosine law to find angles
    cos_C = (b**2 + c**2 - a**2) / (2 * b * c)

    Bx = c
    By = 0

    Cx = b * cos_C 
    Cy = b * math.sqrt(1 - cos_C**2)

    # Return coordinates of A, B, C
    return [(0, 0), (Bx, By), (Cx, Cy)]


def main():
    c, b, m = map(float, input().split())
    coords = find_triangle_coordinates(b, c, m)

    if coords is None:
        print("Mission impossible")
        return

    for x, y in coords:
        print(f"{x:.6f} {y:.6f}")


if __name__ == "__main__":
    main()

=================
statement.txt
======================
151. Construct a triangle
time limit per test: 0.25 sec.
memory limit per test: 4096 KB
input: standard input
output: standard output



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<=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 test(s)

Input
5 5 3

Output
0.00000 3.00000
-4.00000 0.00000
4.00000 0.00000
Author:	Michael R. Mirzayanov
Resource:	Saratov Subregional School Team Contest, 2002
Date:	Spring, 2002








=================
