ACM (TJU) : 1591


#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main ()
{
    double a, b, c;
    int testCase = 0;

    while ( cin >> a >> b >> c ) {

        if ( a == 0 && b == 0 && c == 0 )
        return 0;

        cout << "Triangle #" << ++testCase << endl;

        double res;

        if ( a == -1 ) {
            res = c * c - b * b;
            if ( res <= 0 )
            cout << "Impossible." << endl;
            else
            cout << "a = " << setprecision (3) << fixed << sqrt (res) << endl;
        }

        else if ( b == -1 ) {
            res = c * c - a * a;
            if ( res <= 0 )
            cout << "Impossible." << endl;
            else
            cout << "b = " << setprecision (3) << fixed << sqrt (res) << endl;
        }

        else if ( c == -1 ) {
            res = b * b + a * a;
            if ( res <= 0 )
            cout << "Impossible." << endl;
            else
            cout << "c = " << setprecision (3) << fixed << sqrt (res) << endl;
        }

        cout << endl;

    }

    return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s