305461: CF1036C. Classy Numbers

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Classy Numbers

题意翻译

定义一个数字是“好数”,当且仅当它的十进制表示下有不超过$3$个数字$1 \sim 9$ 举个例子:$4,200000,10203$是“好数”,然而$4231,102306,7277420000$不是 给定$[l,r]$,问有多少个$x$使得$l \le x \le r$,且$x$是“好数” 一共有$T(1 \le T \le 10^{4})$组数据,对于每次的询问,输出一行一个整数表示答案 $1 \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 $ non-zero digits. For example, numbers $ 4 $ , $ 200000 $ , $ 10203 $ are classy and numbers $ 4231 $ , $ 102306 $ , $ 7277420000 $ are not. You are given a segment $ [L; R] $ . Count the number of classy integers $ x $ such that $ 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 $ ( $ 1 \le T \le 10^4 $ ) — the number of segments in a testcase. Each of the next $ T $ lines contains two integers $ L_i $ and $ R_i $ ( $ 1 \le L_i \le R_i \le 10^{18} $ ).

输出格式


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

输入输出样例

输入样例 #1

4
1 1000
1024 1024
65536 65536
999999 1000001

输出样例 #1

1000
1
0
2

Input

题意翻译

定义一个数字是“好数”,当且仅当它的十进制表示下有不超过$3$个数字$1 \sim 9$ 举个例子:$4,200000,10203$是“好数”,然而$4231,102306,7277420000$不是 给定$[l,r]$,问有多少个$x$使得$l \le x \le r$,且$x$是“好数” 一共有$T(1 \le T \le 10^{4})$组数据,对于每次的询问,输出一行一个整数表示答案 $1 \le l_i \le r_i \le 10^{18}$

加入题单

算法标签: