#P11059. Minimum Remainder-Digit Sum Number
Minimum Remainder-Digit Sum Number
Minimum Remainder-Digit Sum Number
You are given two integers n and p. Your task is to find an n-digit number x that satisfies the following conditions:
- The remainder of the sum of the digits of x when divided by p is as small as possible.
- Among all numbers that achieve the minimum remainder as defined in condition 1, x is the smallest in value.
For example, the sum of the digits of 123 is computed as 1+2+3 = 6.
inputFormat
The input consists of two space-separated integers n
and p
, where n
denotes the number of digits and p
is the modulus used to compute the remainder.
outputFormat
Output the n
-digit number x that meets the conditions above.
sample
1 9
9