알고리즘
백준 알고리즘 5347
daehee719
2024. 3. 29. 19:04
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