辗转相除法求GCD。
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long int ll;
ll GCD(ll x, ll y)
{
return !y ? x : GCD(y, x % y);
}
ll LCM(ll x, ll y)
{
return x * y / GCD(x, y);
}
int main()
{
ll a, b;
while (cin >> a >> b)
{
cout << GCD(a, b) << ' ' << LCM(a, b) << endl;
}
return 0;
}