Problems > Digit Sums Divisible by K > Editorial

Digit Sums Divisible by K — Solution & Editorial

Back to the Problem

Digit DP with state = (position, digit-sum mod K, tight). Count over both bounds and subtract.

Complexity: O(digits · K · 10)