Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Difficulty: [show] Hackable ✓
Statistics

这是关于 Kevin 和 Little Cyan Fish 的另一个故事。

Kevin 是国际凸多边形锦标赛(ICPC)的首席裁判。他为比赛提出了一个几何任务。然而,由于他在计算几何方面经验不足,他无法为该任务的测试生成正确的凸多边形。因此,他将注意力转向了一个与字符串相关的问题。

在本题中,我们假设所有字符串仅由小写字母组成。对于字符串 $S = S_0S_1 \dots S_{|S|-1}$,我们用 $|S|$ 表示字符串的长度,$S_i$ 表示字符串的第 $(i+1)$ 个字符。例如,对于 $S = \text{xiaoqingyu}$,有 $|S| = 10$,其中 $S_0 = \text{x}$,$S_1 = \text{i}$,$S_9 = \text{u}$。

字符串 $T$ 被定义为字符串 $S$ 的周期,当且仅当对于每个 $0 \le i < |S|$,等式 $S_i = T_{i \pmod{|T|}}$ 成立。例如,“ccpc” 是 “ccpcccpc” 和 “ccpccc” 的周期,而 “cpc” 不是 “ccpc” 的周期。

Kevin 定义一个字符串序列 $[S_1, S_2, \dots, S_k]$ 为周期性的,当且仅当它满足: 对于所有 $1 \le i < j \le k$,$S_i \neq S_j$ 对于所有 $1 \le i < k$,$S_i$ 是 $S_{i+1}$ 的周期

Kevin 热爱周期性的概念,因此他向 Little Cyan Fish 提出了以下问题: * 对于给定的整数 $n$,满足对于所有 $1 \le i \le \ell$ 都有 $|S_i| \le n$ 的最长周期性序列 $S_1, S_2, \dots, S_\ell$ 的长度(记为 $\ell$)是多少?

设 $f(n)$ 为上述问题对于固定整数 $n$ 的答案。Little Cyan Fish 觉得这个问题太简单了,所以他想知道 $f(1), f(2), \dots, f(N)$ 的值。你能帮他计算这些值吗?由于数值可能非常大,你只需要输出答案对给定的素数 $M$ 取模的结果。

输入格式

输入的第一行包含两个整数 $N$ 和 $M$ ($1 \le N \le 2 \times 10^5$,$5 \times 10^8 \le M \le 1.01 \times 10^9$)。 保证 $M$ 是一个素数。

输出格式

输出一行,包含 $N$ 个整数,表示 $f(1), f(2), \dots, f(N)$ 对 $M$ 取模后的值。

样例

样例输入 1

5 1000000007

样例输出 1

1 3 6 11 19

说明

对于第一个测试用例,我们有 $f(1) = 1, f(2) = 3, f(3) = 6$。 对于 $n = 1$,其中一个可能的周期性序列是 $[\text{a}]$。 对于 $n = 2$,其中一个可能的周期性序列是 $[\text{ab, a, aa}]$。 对于 $n = 3$,其中一个可能的周期性序列是 $[\text{abc, ab, aba, a, aaa, aa}]$。

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.