import java.util.*;
import java.math.*;
class Solution {
public int[] solution(int n, int m) {
BigInteger bigN = new BigInteger(Integer.toString(n));
BigInteger bigM = new BigInteger(Integer.toString(m));
BigInteger gcd = bigN.gcd(bigM);
BigInteger lcm = bigN.multiply(bigM).divide(gcd);
int[] answer = {gcd.intValue(), lcm.intValue()};
return answer;
}
}
이렇게 풀라고 낸 문제는 아닌 것 같은데
있는건 써야..
'공부기록 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 콜라 문제 (0) | 2024.02.04 |
---|---|
[프로그래머스] 스킬트리 (0) | 2024.02.03 |
[프로그래머스] 튜플 (0) | 2024.02.02 |
[프로그래머스] 피로도 (0) | 2024.01.30 |
[프로그래머스] 이진 변환 반복하기 (0) | 2023.12.25 |