Skip to content

Commit

Permalink
B_1934
Browse files Browse the repository at this point in the history
  • Loading branch information
likppi10 committed Nov 1, 2021
1 parent 9ef5b34 commit 53c55dc
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Algorithm_Baek/Basic/B_300/B_1934_최소공배수.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package B_300_수학1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class B_1934_최소공배수 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = null;
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(br.readLine());

for(int tc=0; tc<T; tc++) {
st = new StringTokenizer(br.readLine(), " ");

int a = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());

sb.append(lcm(a,b)+"\n");
}

System.out.println(sb);

}
static int gcd(int a, int b) {
while(b != 0) {
int r = a % b;
a = b;
b = r;
}
return a;
}

static int lcm(int a, int b) {
return a * b / gcd(a, b);
}

}

0 comments on commit 53c55dc

Please sign in to comment.