#P4193. Counting Little D's Favorite Numbers
Counting Little D's Favorite Numbers
Counting Little D's Favorite Numbers
Little D loves numbers with a special property. For any positive integer (n), let (S(n)) be the sum of its digits. Define the function (D(n)) recursively as follows:
$$
D(n)=\begin{cases}
S(n) & \text{if } S(n)<10\
D(S(n)) & \text{if } S(n)\ge10
\end{cases}
A number \(A\) is considered to be one of Little D's favorite numbers if it can be represented in the form
$$A=x\times D(x)$$
for some positive integer \(x\) (with \(D(x)\) being the digital root of \(x\)). Given an interval \([L, R]\), determine how many numbers in this interval are liked by Little D. ## inputFormat The input consists of a single line containing two space-separated integers \(L\) and \(R\) representing the boundaries of the interval. ## outputFormat Output a single integer: the count of numbers in the interval \([L, R]\) that can be expressed as \(x\times D(x)\) for some positive integer \(x\). ## sample
1 100
25
$$