UVA 10773 Solution

#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    double d, v, u, t, r, a = 0;
    long long int i, n;
    cout << showpoint;
    cout << fixed;
    cout << setprecision(3);
    cin >> n;
    for(i=1; i<=n; i++)
    {
        cin >> d >> v >> u;
        if(v>=u || u == 0 || v == 0)
        {
            cout << "Case " << i << ": " << "can't determine" << endl;
        }
        else
        {
            t = d/u;
            r = d/sqrt((u*u) - (v*v));
            a = r-t;
            cout << "Case " << i << ": " << a << endl;
        }
    }
    return 0;
}

Comments