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.
The first line contains the lengths N
and M
, separated by a space. A
is given on the second and B
on the third line. The numbers will not have leading zeros.
Output the product of A
and B
without leading zeros.
1 ≤ N, M
≤ 50 000
3 4
123
4567
561741
3 1
100
0
0
Olympiad > Central European Olympiad in Informatics > CEOI 2017 > Practice 2번
import java.math.BigInteger;
import java.util.Scanner;
public class Code22193 {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int N=sc.nextInt();
int M=sc.nextInt();
BigInteger A=sc.nextBigInteger();
BigInteger B=sc.nextBigInteger();
System.out.println(A.multiply(B));
}
}
BigInteger
를 이용해서 큰 수의 제곱을 multiply()
로 해결했다.