백준/20001 - 25000
[백준] 22193번 : Multiply(JAVA)
lms0806
2021. 7. 25. 19:59
728x90
반응형
https://www.acmicpc.net/problem/22193
22193번: Multiply
Write a program that computes a product of two non-negative integers A and B. The integers are represented in decimal notation and have N and M digits, respectively.
www.acmicpc.net
풀이
숫자가 큰 곱셈입니다.
BigInteger을 사용해서 풀어주면 됩니다.
소스코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
br.readLine();
System.out.print(new BigInteger(br.readLine()).multiply(new BigInteger(br.readLine())));
}
}
728x90
반응형