#include<bits/stdc++.h>
using namespace std;
// gcd(a,b) = gcd(b, a%b): a,b的最大公约数 = b,a%b 的最大公约数
int gcd(int a,int b) {
// return b ? gcd(b,a%b) : a;
if(b==0) return a;
return gcd(b,a%b);
}
int main() {
int t,a,b,c,d; cin>>t;
while(t--) {
cin>>a>>b>>c>>d;
int e = a*d+b*c;
int f = b*d;
int temp = gcd(e,f);
cout<<e/temp<<" "<<f/temp<<endl;
}
return 0;
}
标签:return,gcd,int,20230103code,cin,a%
From: https://www.cnblogs.com/hellohebin/p/17021313.html