

Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 点
問題文
正整数からなる集合 は次の条件を満たすとき、良い集合であるといいます。
- 任意の相異なる 要素 に対して、 を 進法表記した文字列は、 を 進法表記した文字列の部分文字列ではない。
部分文字列とは?
部分文字列とは連続する部分列のことを指します。例えば1
, 12
, 23
は 123
の部分文字列ですが、21
や 13
は 123
の部分文字列ではありません。
正整数 が与えられます。 以上 以下の整数からなる良い集合 の要素数の最大値を求めてください。
個のテストケースが与えられるので、それぞれについて答えを求めてください。
制約
入力
入力は以下の形式で標準入力から与えられます。
各テストケースは以下の形式で与えられます。
出力
行出力してください。 行目には、 に対する答えを出力してください。
入力例 1Copy
3 3 8 3 18 1 1000
出力例 1Copy
6 10 900
はじめの つのテストケースについて、例えば次の が要素数が最大であるような良い集合となります。
- つめのテストケース:.
- つめのテストケース:.
Score : points
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 1Copy
3 3 8 3 18 1 1000
Sample Output 1Copy
6 10 900
For the first two cases, the following are good sets with the maximum number of elements.
- Case : .
- Case : .