import java.math.BigInteger;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
BigInteger n = scan.nextBigInteger();
BigInteger m = scan.nextBigInteger();
System.out.println(n.divide(m));
System.out.println(n.remainder(m));
scan.close();
}
}
int의 메모리 범위는 '-2,147,483,648~2,147,483,647'이다.
BigInteger의 범위는 문자열 형태로 이루어져 있어 무한이다.
문자열 형태로 이루어져 있기에 사칙연산이 안된다.
따라서 BigInteger의 값을 계산을 하려면 클래스 내부의 함수를 이용해야 한다.
더하기 : add()
빼 기 : subtract()
곱하기 : multiply()
나누기 : divide()
'백준알고리즘 > Bronze V' 카테고리의 다른 글
2338번: 긴자리 계산 (0) | 2022.06.20 |
---|---|
1330번: 두 수 비교하기 (0) | 2022.06.19 |
1008번: A/B (0) | 2022.06.19 |
1001번: A-B (0) | 2022.06.19 |
1000번: A+B (0) | 2022.06.19 |