已AC代码:
#include<cstdio>
using namespace std;
int divisor(int x, int y)
{
return y?divisor(y, x%y):x;
}
int main()
{
int t;
scanf("%d", &t);
while(t--)
{
int x, y;
scanf("%d%d", &x, &y);
printf("%d %d\n", divisor(x, y), x*y/divisor(x, y));
}
return 0;
}