[백준] 22193

당당·2023년 6월 17일
0

백준

목록 보기
150/179

https://www.acmicpc.net/problem/22193

📔문제

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


📝예제 입력 1

3 4
123
4567

📺예제 출력 1

561741

📝예제 입력 2

3 1
100
0

📺예제 출력 2

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()로 해결했다.

profile
MySQL DBA 신입 지원

0개의 댓글