QOJ.ac

QOJ

時間限制: 1.0 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#12821. 优美数

统计

在 $d$ 进制表示法中,如果一个整数 $K = (A_1 A_2 \dots A_m)_d$(其中 $A_i \in [0, d)$ 且 $A_1 \neq 0$)满足 $A_1, \dots, A_m$ 是 $0$ 到 $d-1$ 的一个排列,则称该整数为“好数”(good)。

如果一个数 $K$ 至少存在一个 $d \ge 2$ 使得 $K$ 在 $d$ 进制表示法下是“好数”,则称该数 $K$ 为“优数”(nice)。

计算区间 $[L, R]$ 内“优数”的个数。由于答案可能非常大,请输出其对 $998\,244\,353$ 取模的结果。

输入格式

输入的第一行包含两个整数 $L$ 和 $R$ ($1 \le L \le R \le 10^{5000}$)。

输出格式

输出一行,包含一个整数:答案对 $998\,244\,353$ 取模的结果。

样例

样例输入 1

5 20

样例输出 1

3

样例输入 2

123456 123456789

样例输出 2

114480

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
#178EditorialOpen题解jiangly2025-12-12 23:56:10View

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.