Problem description gives you two scores, asks for their sum, and asks for the sum and the simplest form.
Input first contains a positive integer T (t <= 1000), indicating that there are T groups of test data, followed by T rows of data, each line contains four positive integers a, B, c, D (0 <1000) indicates two scores, A/B and C/D.
Output outputs two integers E and F for each group of test data, indicating that the simplest result of A/B + C/D is E/F, and each group of output occupies one row.
Sample Input
2 1 2 1 3 4 3 2 3 Sample output
5 6 2 1
# Includeint Yue (int m, int N) // obtain the maximum approximate number of molecular denominator {int T, R; If (M> N) {T = N; n = m; M = T;} while (m) {r = n % m; n = m; M = r;} return N;} int main () {int T,, b, c, d; int n, m, K; scanf ("% d", & T); While (t --) {scanf ("% d", & A, & B, & C, & D); M = B * D; // Denominator = A * D + B * C; // the numerator after the denominator is added if (M = N) // The condition where the numerator and denominator are the same {printf ("1 1 \ n"); continue;} k = Yue (m, n ); printf ("% d \ n", N/K, M/K); // simplification of molecules and denominator} return 0 ;}