mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
34806a93cd
2500-2599
27 lines
457 B
C++
27 lines
457 B
C++
#include<stdio.h>
|
|
int gcd(int x,int y)
|
|
{
|
|
if(x==y)
|
|
return x;
|
|
if(x>y)
|
|
return gcd(x-y,y);
|
|
if(x<y)
|
|
return gcd(x,y-x);
|
|
}
|
|
int main()
|
|
{
|
|
int a,b,c,d,e,f,g;
|
|
int n;
|
|
while(scanf("%d",&n)!=EOF)
|
|
{
|
|
while(n--)
|
|
{
|
|
scanf("%d%d%d%d",&a,&b,&c,&d);
|
|
e=a*d+b*c;
|
|
f=b*d;
|
|
g=gcd(e,f);
|
|
printf("%d %d\n",e/g,f/g);
|
|
}
|
|
}
|
|
}
|