水题
#include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int T; int a,b,c,d; int gcd(int a,int b) { int t; while(b) { t = a%b; a = b; b = t; } return a; } int main() { scanf("%d",&T); while(T--) { scanf("%d%d%d%d",&a,&b,&c,&d); int x=a*d+b*c; int y=b*d; int z=gcd(x,y); printf("%d %d ",x/z,y/z); } return 0; }