AtCoder Grand Contest 057
翻译中…
Problem Statement
翻译中…
A set $A$ of positive integers is said to be good when it satisfies the following condition.
翻译中…
- For any two distinct elements
$a, b \in A$, the string representing$a$in base ten is not a substring of the string representing$b$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 $L$ and $R$. Find the maximum possible number of elements in a good set $A$ consisting of integers between $L$ and $R$ (inclusive).
翻译中…
We will give you $T$ test cases; solve each of them.
翻译中…
Constraints
翻译中…
$1\leq T\leq 10^4$$1\leq L\leq R\leq 10^{9}$
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
T
\text{case}_1
\vdots
\text{case}_T
翻译中…
Each case is in the following format:
翻译中…
L R
翻译中…
Output
翻译中…
Print $T$ lines. The $i$-th line should contain the answer for $\text{case}_i$.
翻译中…
样例
Input #1
3
3 8
3 18
1 1000
Output #1
6
10
900
For the first two cases, the following are good sets $A$ with the maximum number of elements.
- Case $1$: $A=\{3,4,5,6,7,8\}$.
- Case $2$: $A=\{3,4,6,8,9,10,11,12,15,17\}$.
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。