Oneness
Time limit2sMemory limit512 MB
Given an l-digit number n generated by a pseudo-random generator, sum the count of repunit divisors greater than 1 over all integers from 1 to n.
- Level
Hard8 of 10
- Topics
- Number theory, Math, Implementation
- Solved
- No attempts yet
Problem
Define the oneness of a number as the number of integers that divide and whose decimal representation consists only of the digit . For example, and .
The number is generated by a pseudo-random number generator. You are given two integers and , where is the number of digits in the decimal representation of and is the seed of the generator. The digits of are generated by the following recurrences:
It is guaranteed that is non-zero. Calculate the total oneness over all integers between and .
Input
The first line contains two integers and (, ).
Output
Output the sum of the oneness over all integers between and .
Hint
In the sample tests, equals 1, 11, 1221, and 9359, respectively.