Equation
Time limit1sMemory limit256 MB
Count integers n in [a,b] with k times the sum of squared digits of n equal to n, where a and b go up to 10^18.
- Level
Medium7 of 10
- Topics
- Dynamic programming, Math, Brute force, Implementation
- Solved
- No attempts yet
Problem
For a positive integer , let be the sum of the squares of the digits in its decimal representation. Given three integers , determine the number of natural numbers such that and satisfies the equation [ k\cdot f(n) = n. ]
Input
The first and only line contains the three integers from the statement: (, ).
Output
Output a single integer: the number of integer solutions of the equation that lie in the range .
Hint
In the example, the only positive integers in the range that satisfy the equation for are , and .