PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000172. Số Smith (Smith Numbers)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Số Smith (Smith Numbers)
Smith Numbers
Phuoc Hung OJ ID: PRIME000177
Original source: UVa 10042
Problem statement
A Smith number is a composite integer whose digit sum equals the sum of the digits of all its prime factors, with multiplicity. Given , find the smallest Smith number strictly greater than .
Input
One positive integer .
Output
Print the smallest Smith number strictly greater than .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
The result may be greater than the maximum input value.
Example
Input
4937774
Output
4937775
Explanation: The factorization is . Both digit sums equal , and this is the first Smith number above the input.