-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
|
||
} |