728x90
import java.io.*;
import java.util.*;
public class Main {
static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); //선언
public static void main(String[] args) throws IOException{
String s = bf.readLine();
int i = Integer.parseInt(s);
for (int j = 0; j < i; j++) {
String s1 = bf.readLine();
String parts[] = s1.split(" ");
long a = Integer.parseInt(parts[0]);
long b = Integer.parseInt(parts[1]);
System.out.println(a*b/gcd(a,b));
}
}
public static long gcd(long a, long b)
{
if(a%b == 0)
return b;
return gcd(b,a%b);
}
}
728x90
'알고리즘' 카테고리의 다른 글
백준 알고리즘 2609 (1) | 2024.03.29 |
---|---|
백준 알고리즘 9934 (0) | 2024.03.29 |
백준 알고리즘 2075 (0) | 2024.03.29 |
백준 알고리즘 2800 (0) | 2024.03.29 |
백준 알고리즘 10828 (0) | 2024.03.29 |