Digit Sums
Time limit1sMemory limit128 MB
Count positive integers up to A whose base-B digits add up to C for each query line.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Math
- Solved
- No attempts yet
Problem
You are given three positive integers , , and . How many positive integers not greater than have digits that sum to when the number is written in base ?
Input
The input is a series of lines. Each line holds three integers , , and separated by one or more blanks, with and . All three numbers are given in base 10. A line containing three zeros ends the input and is not processed.
Output
For each input line, print the number of such integers in base 10, one per line.