#B4032. Optimal N-Digit Number with Minimal Digit Sum Remainder
Optimal N-Digit Number with Minimal Digit Sum Remainder
Optimal N-Digit Number with Minimal Digit Sum Remainder
Given two integers n and p, find an n-digit number x such that:
- The remainder when the sum of the digits of x is divided by p is as minimal as possible.
- Among all numbers satisfying condition 1, x is the smallest possible.
Note: The sum of digits of a number is defined as the sum of its individual digits. For example, the sum of digits of \(123\) is \(1+2+3=6\).
inputFormat
The input consists of a single line containing two integers n and p, where n is the number of digits and p is the divisor. Note that the number x must have exactly n digits with no leading zeros.
outputFormat
Output the n-digit number x satisfying the above conditions.
sample
1 5
5