mirror of
https://github.com/tiennm99/codechef.git
synced 2026-06-10 08:11:07 +00:00
29 lines
439 B
C++
29 lines
439 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
unsigned long long int gcd(int a, int b) {
|
|
unsigned long long int temp;
|
|
while (b != 0)
|
|
{
|
|
temp = a % b;
|
|
a = b;
|
|
b = temp;
|
|
}
|
|
return a;
|
|
}
|
|
|
|
int main()
|
|
{
|
|
unsigned long long int t, a, b, l, g;
|
|
cin >> t;
|
|
while (t--)
|
|
{
|
|
cin >> a >> b;
|
|
g = gcd(a, b);
|
|
l = a*b/g;
|
|
cout << g << " " << l << endl;
|
|
}
|
|
return 0;
|
|
}
|