##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
Counting numbers in huge ranges seems impossible. Digit DP builds answers digit by digit.
Count numbers where digit sum is divisible by D - foundational.
No adjacent same digits - teaches tight bound and leading zeros.
Understanding the constraint
Exactly K non-zero digits - handles N up to 100 digits.
At most 3 non-zero digits - practice count parameter in state.
Restricted digit set - handling which digits can be used.
Positional constraints + divisibility - advanced digit DP.
Covered with full walkthrough in this section.
Covered with full walkthrough in this section.
Count numbers with d at even positions only, divisible by m. Classic digit DP.
Count numbers with at most 3 non-zero digits. Digit DP tracking non-zero count.
Count numbers where all digits appear even times in base b. Multi-base digit DP.
Count pairs where a XOR b = a + b. Two-variable digit DP on binary representation.
Count numbers reaching 1 in exactly k steps via popcount. Digit DP + precomputation.
Sum of numbers using at most k distinct digits. Digit DP tracking digit set.
Count integers with digit sum in range. Standard digit DP with sum tracking.
Adjacent digits differ by 1. Digit DP tracking last digit placed.
Equal even/odd digits and divisible by k. Multi-constraint digit DP.
Count numbers with at least one repeated digit. Complement counting with digit DP.