Practice · 3 of 3
Exact Digit-Sum Count
CHALLENGE
Difficulty: advanced+25 XP
**Problem.** Each line: L R K (read until EOF). Print one integer per line: the count of x in [L, R] with digit sum exactly K. **Constraints:** 1 ≤ q ≤ 20000; 1 ≤ L ≤ R ≤ 10^18; 1 ≤ K ≤ 162. Budget-state digit DP: (position, remaining budget, tight). The W drops the tight chain and undercounts every boundary.
Press Submit to check your solution.
Back to lesson: Practice: Digit Trio