cswork / OA打开练习工作台

BloombergOA #2

Ashley Loves Numbers (Financial Engineer)

估计中等可在线判题

考点(AI 标注)前缀和区间位运算

For each closed interval [n,m], count the positive integers whose decimal representation has all distinct digits. 0 is a digit too, and appearing twice counts as a repeat; no leading zeros are added.

输入格式

This site's simplified input protocol: the first line contains q, followed by q lines each with two integers n m (the fixed column count 2 of the original function wrapper is omitted). 1≤q≤100000, 1≤n≤m≤1000000.

输出格式

Output one count per line, in query order.

样例 1

输入:

2
1 20
11 11

输出:

19
0

样例 2

输入:

2
98 102
100 100

输出:

2
0

样例 3

输入:

3
1 9
10 10
123 123

输出:

9
1
1

样例说明

From 1 to 20 only 11 is invalid, giving 19; from 98 to 102 only 98 and 102 are valid; the single points 10 and 123 are both valid, while 100 is invalid because 0 repeats.