import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
// Input Supply Cable
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
for (int i = 0; i < T; i++) {
// Preprocessing
int A = sc.nextInt();
int B = sc.nextInt();
// Operating LCM
int result = A*B / GCD(Math.max(A, B), Math.min(A, B));
// Output Extracting Cable
System.out.println(result);
}
}
// External Module
public static int GCD(int Bigger, int Smaller) {
int r = Bigger % Smaller;
if (r == 0)
return Smaller;
else
return GCD(Smaller, r);
}
}
-
// Operating GCD(1/2)
long GCD = GCD(Math.max(A, B), Math.min(A, B));
// External Module(1/2)
private static long GCD(long B, long S) {
long r = B % S;
while (r != 0) {
r = B%S;
B = S;
S = r;
}
return Math.abs(B);
}
'Hard deck > Module' 카테고리의 다른 글
Extended Euclidean (0) | 2022.08.04 |
---|---|
Euclidean (0) | 2022.08.04 |
(O.E Cable) BufferedWriter (0) | 2022.08.04 |
External Module and Access Opener (0) | 2022.08.04 |
000 : Split Split (0) | 2022.07.30 |