[恢]hdu 2503
2011-12-16 04:48:40
地址:http://acm.hdu.edu.cn/showproblem.php?pid=2503
题意:中文。水。
代码:
# include <stdio.h>
int gcd(int a, int b){return a%b?gcd(b,a%b):b;}
int main ()
{
int T ;
int a, b, c, d, e, f, g ;
scanf ("%d", &T) ;
while (T--)
{
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) ;
}
return 0 ;
}