zrq495
www.zrq495.com
 1 #include<iostream>
 2 
 3 using namespace std;
 4 
 5 int gcd(int a, int b)
 6 {
 7     return b?gcd(b, a%b):a;
 8 }
 9 
10 int main()
11 {
12     int a, b, c, d, m, k;
13     int n;
14     cin >> n;
15     while(n--)
16     {
17         cin >> a >> b >> c >> d;
18         int t=gcd(b,d);
19         m=a*d/t+b*c/t;
20         k=gcd(m, b*d/t);
21         cout << m/k << " " << b*d/t/k << endl;
22     }
23     return 0;
24 }
posted on 2012-07-31 14:19  zrq495  阅读(111)  评论(0编辑  收藏  举报