#DP1024. Classy Numbers

Classy Numbers

Classy Numbers

题面翻译

定义一个数字是“好数”,当且仅当它的十进制表示下有不超过 33191 \sim 9 之间的数字。

举个例子:4,200000,102034,200000,10203 是“好数”,然而 4231,102306,72774200004231,102306,7277420000 不是

给定 [l,r][l,r],问有多少个 xx 使得 lxrl \le x \le r,且 xx 是“好数”

一共有 T(1T104)T(1 \le T \le 10^{4}) 组数据,对于每次的询问,输出一行一个整数表示答案

1liri10181 \le l_i \le r_i \le 10^{18}

题目描述

Let's call some positive integer classy if its decimal representation contains no more than 3 3 non-zero digits. For example, numbers 4 4 , 200000 200000 , 10203 10203 are classy and numbers 4231 4231 , 102306 102306 , 7277420000 7277420000 are not.

You are given a segment [L;R] [L; R] . Count the number of classy integers x x such that LxR L \le x \le R .

Each testcase contains several segments, for each of them you are required to solve the problem separately.

输入格式

The first line contains a single integer T T ( 1T104 1 \le T \le 10^4 ) — the number of segments in a testcase.

Each of the next T T lines contains two integers Li L_i and Ri R_i ( 1LiRi1018 1 \le L_i \le R_i \le 10^{18} ).

输出格式

Print T T lines — the i i -th line should contain the number of classy integers on a segment [Li;Ri] [L_i; R_i] .

样例 #1

样例输入 #1

4
1 1000
1024 1024
65536 65536
999999 1000001

样例输出 #1

1000
1
0
2