→ Attention
The package for this problem was updated by the problem writer or WyOJ administration after we've upgraded the judging servers. To adjust the time limit constraint, a solution execution time will be multiplied by 1. For example, if your solution works for 623 ms on judging servers, then the value 623 ms will be displayed and used to determine the verdict.
Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if and only if it is divisible by each of its nonzero digits. We will not argue with this and just count the quantity of beautiful numbers in given ranges.
一个正整数是美丽的当且仅当它可以被自己的所有非 $0$ 数位整除。我们需要计算给定区间内美丽的正整数数量。
Input
第一行包含测试用例数量 $t$($1 \le t \le 10$)。以下 $t$ 行中每一行包含两个自然数 $l_i$ 和 $r_i$($1 \le l_i \le r_i \le 9 \times 10^{18}$)。
Please, do not use %I64d specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %lld).
Output
输出应当包含 $t$ 个数字——每个询问的答案,一个数字一行,表示区间 $[l_i, r_i]$ 中美丽的正整数数量。
Examples
Input
1 1 9Output
9
Input
1 12 15Output
2
Input
9 357816591093473912 478906145736655650 154072099530098530 297675544560923083 853274171983555776 877332810632329118 258601077826366175 856890041027686262 151084241340128367 868279055062218946 360302714872207562 400114081267420149 15181634044326791 602401427137909762 85295343866069509 372373854804747278 61825864286248332 820583114541565140Output
262303539156695 312897266661597 38778726789519 1139862940345127 1402615778591617 79118901111096 1245376292216844 659738283968181 1512151848646298

鲁ICP备2025150228号