Compute the digital root of all integers from 1 to n and sum the results modulo k.
Given two integers and , consider every integer from $1n$ inclusive. For each number, repeatedly replace it with the sum of its digits until only one digit remains. This final value is called the digital root.
Your task is to compute the sum of the digital roots of all numbers from $1nk$.
Example 1
Input
5 10
Output
15
Explanation
Digital roots of 1..5 are 1, 2, 3, 4, 5. Their sum is 15, and 15 mod 10 = 5. However, since the problem asks for the sum modulo k, the output is 5. If using the common Codeforces sample, verify the input/output pair accordingly.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.