Tap here to switch tabs
Problem
Submissions

Problem: Sum of K-Digit Numbers in a Range

Try to solve the Sum of K-Digit Numbers in a Range problem.

Statement

You are given three integers l, r, and k.

Consider all valid sequences of length k where each digit is an integer chosen from the inclusive range [[l$, ‘r‘`r`]$. Each sequence forms a kk digit number where positions represent powers of 1010.

Return the sum of all such numbers. Since the answer may be large, return it modulo 109+710^9 + 7.

Note: Numbers with leading zeros are evaluated by their standard numeric value.

Constraints:

  • 0≤0 \le l ≤\le r ≤9\le 9

  • 1≤1 \le k ≤109\le 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sum of K-Digit Numbers in a Range

Try to solve the Sum of K-Digit Numbers in a Range problem.

Statement

You are given three integers l, r, and k.

Consider all valid sequences of length k where each digit is an integer chosen from the inclusive range [[l$, ‘r‘`r`]$. Each sequence forms a kk digit number where positions represent powers of 1010.

Return the sum of all such numbers. Since the answer may be large, return it modulo 109+710^9 + 7.

Note: Numbers with leading zeros are evaluated by their standard numeric value.

Constraints:

  • 0≤0 \le l ≤\le r ≤9\le 9

  • 1≤1 \le k ≤109\le 10^9