#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss stable_sort
#define ll long long
int gcd(int x, int y) {
int r;
while (y!=0) {
r = x % y;
x = y;
y = r;
}
return x;
}
int main() {
cin.tie(0)->sync_with_stdio(0);
// for(int i=0; i< n;i++)
int t;
cin >> t;
int x, y;
while(t--){
cin >> x >> y;
cout << (x * y) / gcd(x, y) << " ";
cout << gcd(x,y) << "\n";
}
return 0;
}
'백준 풀이 C++' 카테고리의 다른 글
백준 3020 c++ (이분탐색) (1) | 2022.09.24 |
---|---|
백준 7785 c++ set 역순 출력 (1) | 2022.09.23 |
백준 15651 N과M(3) (백트래킹) (0) | 2022.09.22 |
백준 15650 N과 M(2) C++ (백트레킹) (0) | 2022.09.22 |
백준 15649 C++ (백트래킹) (0) | 2022.09.22 |