题目来源:http://acm.nyist.net/JudgeOnline/problem.php?pid=40
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int Euler_Gcd(int a, int b)
{
if(b == 0)
return a;
return Euler_Gcd(b, a%b);
}
int main()
{
int T;
int a, b, gcd, lcm;
scanf("%d", &T);
while(T--)
{
scanf("%d %d", &a, &b);
gcd = Euler_Gcd(a, b);
lcm = a/gcd * b;//先除后乘,如果数据很大的话,不会导致溢出!
printf("%d %d\n", gcd, lcm);
}
return 0;
}