P2567 [SCOI2010] Lucky Numbers
Background
Sichuan NOI Qualifier 2010.
Description
In China, many people consider $6$ and $8$ to be lucky numbers. lxhgww thinks so too, so he defines his own "lucky numbers" as those whose decimal representation contains only the digits $6$ and $8$. For example, $68$, $666$, and $888$ are all "lucky numbers". However, there are too few such "lucky numbers"; for instance, in the interval $[1,100]$ there are only $6$ of them ($6$, $8$, $66$, $68$, $86$, $88$). Therefore, he further defines "almost lucky numbers": any multiple of a "lucky number" is an "almost lucky number". Of course, any "lucky number" is also an "almost lucky number". For example, $12$, $16$, and $666$ are all "almost lucky numbers".
Now lxhgww wants to know how many "almost lucky numbers" there are in a closed interval $[a, b]$.
Input Format
The input is a single line containing $2$ numbers $a$ and $b$.
Output Format
Output a single line containing $1$ number, the count of "almost lucky numbers" in the closed interval $[a, b]$.
Explanation/Hint
For $30\%$ of the testdata, it is guaranteed that $1 \le a \le b \le 10^6$.
For $100\%$ of the testdata, it is guaranteed that $1 \le a \le b \le 10^{10}$.
Translated by ChatGPT 5