#agc057a. [agc057_a]Antichain of Integer Strings
[agc057_a]Antichain of Integer Strings
Problem Statement
A set of positive integers is said to be good when it satisfies the following condition.
- For any two distinct elements , the string representing in base ten is not a substring of the string representing in base ten.
What is a substring? A substring of a string is its contiguous subsequence. For example, 1
, 12
, and 23
are substrings of 123
, while 21
and 13
are not.
You are given positive integers and . Find the maximum possible number of elements in a good set consisting of integers between and (inclusive).
We will give you test cases; solve each of them.
Constraints
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
Print lines. The -th line should contain the answer for .
Sample Input 1
3
3 8
3 18
1 1000
Sample Output 1
6
10
900
For the first two cases, the following are good sets with the maximum number of elements.
- Case : .
- Case : .