QOJ.ac

QOJ

Time Limit: 1.5 s Memory Limit: 1024 MB Total points: 100 Hackable ✓

#9923. 我最好的敌人

Statistics

Ekko 刚刚发明了 Z-Drive,这使他能够回到过去。Heimerdinger 开发了这个装置,旨在将 Ekko 送回正确的宇宙。

然而,由于异常导致的时空扭曲,有 $n$ 个 Ekko 被传送到了这个宇宙。很难找到将他们送回哪里,因此 Heimerdinger 发明了一种方法来确定这些 Ekko 属于哪个宇宙。共有 $m$ 个宇宙,该方法的工作流程如下:

  • Ekko 的编号为 $0$ 到 $n-1$,并被划分为若干组。最初,所有 Ekko 都在同一个组中。
  • Heimerdinger 选择一个组,并尝试确定他应该将这些 Ekko 送往哪个宇宙。
  • Heimerdinger 从 $[1, m]$ 中选择一个“好”整数 $x$。一个整数 $x$ 被认为是“好”的,当且仅当对于该组中的每个 Ekko $i$,编号为 $(i + x) \pmod n$ 的 Ekko 也在该组中。例如,如果所选组包含 Ekko $0, 2$,且 $n = 4$,则 $x = 3$ 不是“好”的,而 $x = 2$ 和 $x = 4$ 是“好”的。
  • 然后,Heimerdinger 将该组中的 Ekko 划分为若干个临时组。这种划分确保对于任何临时组中的每个 Ekko $i$,编号为 $(i + x) \pmod n$ 的 Ekko 与 Ekko $i$ 处于同一个临时组中。在所有可能的划分中,Heimerdinger 会选择使临时组数量最多的那种划分。例如,当 $n = 4$ 且该组包含 $\{0, 1, 2, 3\}$ 时,选择 $x = 2$ 会将该组划分为两个临时组 $\{0, 2\}$ 和 $\{1, 3\}$。
  • 如果只有一个临时组,则该组中的所有 Ekko 都被送回宇宙 $x$。否则,每个临时组都成为一个新的组,并对新形成的组重复上述过程。

尽管这种判别方法存在一些小问题,例如将多个 Ekko 送回同一个宇宙,但没有时间去解决它。给定 $n, m$,你需要计算这种判别方法产生的结果数量,结果对 $998\,244\,353$ 取模。当且仅当在两种结果中,有某个 Ekko 被送回了不同的宇宙时,这两种结果才被视为不同。

输入格式

第一行包含两个整数 $n, m$ ($1 \le n, m \le 10^{18}$),分别表示 Ekko 的数量和宇宙的数量。

输出格式

输出一行一个整数,表示答案对 $998\,244\,353$ 取模后的结果。

样例

输入 1

4 4

输出 1

6

输入 2

2338 1470

输出 2

18530141

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.