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();
String parts[] = s.split(" ");
int n = Integer.parseInt(parts[0]);
int k = Integer.parseInt(parts[1]);
if(n==k)
{
System.out.println(n);
System.out.println(n);
return;
}
int big;
int small;
if(n>k)
{
big = n;
small = k;
}
else {
big = k;
small = n;
}
int gcd = big*small;
int x;
while (small != 0)
{
x = big%small;
big = small;
small = x;
gcd = big;
}
System.out.println(gcd);
System.out.println(n*k/gcd);
}
}
728x90
'알고리즘' 카테고리의 다른 글
백준 알고리즘 5347 (2) | 2024.03.29 |
---|---|
백준 알고리즘 9934 (0) | 2024.03.29 |
백준 알고리즘 2075 (0) | 2024.03.29 |
백준 알고리즘 2800 (0) | 2024.03.29 |
백준 알고리즘 10828 (0) | 2024.03.29 |