1 # include <iostream> 2 using namespace std; 3
//辗转相除法 4 int gcd(int a, int b) { 5 if (b == 0) return a; 6 return gcd(b, a%b); 7 } 8 9 int lcm(int a, int b) { 10 return a*b / gcd(a, b); 11 } 12 13 int main() { 14 int a, b; 15 while (cin >> a >> b) { 16 cout << gcd(a, b) << endl; 17 cout << lcm(a, b) << endl; 18 } 19 return 0; 20 }