当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

7056:X-liked Counting

题目描述
David is alway fond of new kinds of numbers.

He defines a number $x-liked$ if any of its prefixes or suffixes can be divided by $x$. A prefix is a contiguous part which begins at the leftmost position of the number and ends at any position of the number, and a suffix is a contiguous part which begins at any position of the number and ends at the rightmost position of the number. For example, $12$ is a prefix of $123$ while $23$ is a suffix of it. The number itself can be a prefix or a suffix of itself.

Now David wants to know how many $x-liked$ integers there are in the range $[l,r]$. However, since David doesn't like the number $7$, he won't allow digit $7$ to occur in the numbers, so you don't need to count in numbers like $27$,$372$,$774$ etc. because they all have at least one digit equals to $7$. Please tell him how many $x-liked$ integers there are in the range $[l,r]$ with no digit equals to $7$.
输入解释
The first line contains one integer $T$($1 \leq T \leq 10$) , the number of testcases.

For each testcase, there is one line which contains three non-negative integers, $l$,$r$ and $x$.

$1 \leq l \leq r \leq 10^{18}$
$1 \leq x \leq 500$
输出解释
For each testcase, output one number in one line, how many $x-liked$ integers there are in the range $[l,r]$ with no digit equals to $7$.
输入样例
1
11 20 4
输出样例
5
来自杭电HDUOJ的附加信息
Hint In the sample, there are five valid integers, 12(12 can be divided by 4), 14(4 can be divided by 4), 16(16 can be divided by 4), 18(8 can be divided by 4), 20(20 and 0 both can be divided by 4).

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-7056

最后修改于 2021-10-23T19:11:14+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
16000/8000MS(Java/Others) 131072/131072K(Java/Others)