Problems > Digit Sums Divisible by K

Digit Sums Divisible by K

Difficulty: 1900 3000 ms 128 MB

digit-dp

Count the integers in [L, R] whose digit sum is divisible by K.

Input: the first line has L, R and K.

Output: the count of qualifying integers.

Constraints:

  • 1 ≤ L ≤ R ≤ 1018
  • 2 ≤ K ≤ 100

Sample Tests

Input 1
1 20 3
Output 1
6
Input 2
10 10 5
Output 2
0

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.