Uva 12502 Solution

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, s, r, i;
    cout << noshowpoint;
    while(cin >> r)
    {
        for(i=1; i<=r; i++)
        {
            cin >> n >> m >> s;
            double t = (double)s/(double)(n+m);
            if(n >= m)
            {
                double p = t*n;
                p = p + (t * (n-m));
                cout << p << endl;
            }
            else if(n<m)
            {
                double p = t*n;
                p = p - (t * (m-n));
                cout << p << endl;
            }
        }
    }

    return 0;
}

Comments