测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A8018. Beautiful numbers

编程题 普及/提高-

题目描述

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.

输入格式

The first line of the input contains the number of cases $t$ ( $1<=t<=10$ ). Each of the next $t$ lines contains two natural numbers $l_{i}$ and $r_{i}$ ( $1<=l_{i}<=r_{i}<=9·10^{18}$ ).

Please, do not use %lld specificator to read or write 64-bit integers in C++. It is preffered to use cin (also you may use %I64d).

输出格式

Output should contain $t$ numbers — answers to the queries, one number per line — quantities of beautiful numbers in given intervals (from $l_{i}$ to $r_{i}$ , inclusively).

输入输出样例

输入 #1
1
1 9
输出 #1
9
输入 #2
1
12 15
输出 #2
2
上一题 去做题 下一题