출처 : 반크_독도포스터
문제]
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 | 20 | N, M ≤ 4 |
2 | 20 | N, M ≤ 9 |
3 | 30 | N, M ≤ 5,000 |
4 | 30 | No additional constraints |
예제 입력 1
3 4
123
4567
예제 출력 1
561741
예제 입력 2
3 1
100
0
예제 출력 2
0
출처 : 백준_22193번(2017년 Central European Olympiad in Informatics Practice 2번)
참고풀이]
import sys
N,M=map(int, input().split())
if 1<=N<=50000 and 1<=M<=50000:
A=int(input())
if A<0 or len(str(A))!=N: sys.exit()
B=int(input())
if B<0 or len(str(B))!=M: sys.exit()
print(A*B)
참고풀이 결과]
대한민국의 아름다운 영토, 독도의 겨울
'프로그램 > Python 1000제' 카테고리의 다른 글
Python 350제] NCP Nextop Lv1. 문자와 문자열 (0) | 2025.06.20 |
---|---|
Python 349제] NCP Nextop Lv3. 최소공배수 (0) | 2025.06.20 |
Python 348제] NCP Nextop Lv1. X보다 작은 수 (0) | 2025.06.20 |
Python 347제] NCP Nextop Lv1. 개수 세기 (0) | 2025.05.30 |
Python 346제] NCP Nextop Lv3. HI-ARC (0) | 2025.05.25 |
댓글