Equation
Time limit2sMemory limit512 MB
Count integers n in [a, b] up to 10^18 with k times the sum of squares of n's decimal digits equal to n.
- Level
Hard8 of 10
- Topics
- Math, Brute force, Dynamic programming, Number theory
- Solved
- No attempts yet
Problem
For a positive integer , let be the sum of the squares of its decimal digits. You are given three positive integers . Determine how many positive integers satisfy and are solutions of the equation
Input
The first and only line of input contains the three integers from the statement. (, )
Output
Your program should print one integer: the number of solutions of the equation in the interval .
Hint
The only positive integers in the interval that satisfy the equation for are 7293, 7854, and 7905.