Codeforces Beta Round 51
D
Beautiful numbers
Codeforces
2500
原题
← CE →
翻译中…

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.

翻译中…

Input

翻译中…

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

翻译中…

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).

翻译中…

样例

Input #1
1
1 9
Output #1
9
InputCopy OutputCopy
Input #2
1
12 15
Output #2
2
InputCopy OutputCopy
题目信息
题号
55D
时间限制
4 s
内存限制
256 MB
标签
动态规划
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。