Uva 12502 - Three Families
Solution Link:: Uva 12502 Solution
// Verdict :: Accepted // Time :: 0.000 #include <iostream> #include <cstdio> #include <cstring> #include <string> #include <vector> #include <cmath> #include <cctype> #include <set> #include <list> #include <stack> #include <queue> #include <algorithm> #define sf scanf #define pf printf #define N 10000 #define MOD 10000000007 #define pb push_back #define ps push #define clr clear using namespace std; int main() { int t; cin >> t; while (t--) { double x,y,z,a,b,c,d; double tc; sf ("%lf%lf%lf",&x,&y,&z); if (x<y) { a = (z*x)/(x+y); //pf (" %lf ",a); b = (z*y)/(x+y);//pf (" %lf ",b); c = b-a; //pf (" %lf ",c); d = a-c; //pf (" %lf ",d); tc = d; if (tc<=0.0) { pf ("0\n"); } else { pf ("%0.lf\n",tc); } } else { a = (z*x)/(x+y); //cout << a << " "; b = (z*y)/(x+y);//cout << b << " "; c = a+(a-b); tc = c ; //cout << c << " "; if (tc<=0.0) { pf ("0\n"); } else { tc = c; pf ("%0.lf\n",tc); } } //cout << endl; } return 0; }
Comments
Post a Comment