QOJ.ac

QOJ

时间限制: 2.0 s 内存限制: 1024 MB 总分: 100

#7547. 整数之美

统计

数论学家 Beata 被数字之美所吸引。给定一个 $n$ 位的整数 $a = a_1 a_2 \dots a_n$ 和一个正整数 $k$,如果 $a$ 的所有数位之积(即 $a_1 \cdot a_2 \cdot a_3 \cdot \dots \cdot a_n$)能被 $k$ 整除,则称 $a$ 为 $k$-特殊数。注意,数字 $0$ 能被任何正整数整除。

例如,若 $a = 2349$ 且 $k = 12$,则 $a$ 的所有数位之积为 $2 \cdot 3 \cdot 4 \cdot 9 = 216$,该积能被 $k = 12$ 整除,因此 $2349$ 是 $12$-特殊数。若 $a = 2349$ 且 $k = 16$,则 $a$ 的所有数位之积 $2 \cdot 3 \cdot 4 \cdot 9 = 216$ 不能被 $k = 16$ 整除,因此 $2349$ 不是 $16$-特殊数。

给定三个整数 $k, L$ 和 $R$,编写一个程序,求 $x \pmod{998\,244\,353}$,其中 $x$ 是区间 $[L, R]$ 内 $k$-特殊数的个数。

输入格式

输入包含一行,包含三个整数 $k, L$ 和 $R$ ($1 \le k \le 10^{17}, 1 \le L \le R \le 10^{20}$)。

输出格式

输出一行。该行应包含 $x \pmod{998\,244\,353}$,其中 $x$ 是区间 $[L, R]$ 内 $k$-特殊数的个数($L$ 和 $R$ 均包含在区间内)。

样例

输入 1

5 1 20

输出 1

4

输入 2

5 50 100

输出 2

19

输入 3

15 11 19

输出 3

0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.