QOJ.ac

QOJ

حد الوقت: 2.0 s حد الذاكرة: 256 MB مجموع النقاط: 100 قابلة للهجوم ✓

#14101. Counting Phenomenal Arrays

الإحصائيات

如果一个由正整数组成的数组 $[a_1, a_2, \dots, a_k]$ 满足其所有元素的乘积等于其所有元素的和(即 $a_1 a_2 \dots a_k = a_1 + a_2 + \dots + a_k$),则称该数组是奇妙的(phenomenal)。

例如,数组 $[2, 2]$ 是奇妙的,因为 $2 \cdot 2 = 2 + 2 = 4$;$[3, 1, 2]$ 也是奇妙的,因为 $3 \cdot 1 \cdot 2 = 3 + 1 + 2 = 6$;但数组 $[2, 3]$ 不是奇妙的,因为 $2 \cdot 3 \neq 2 + 3$。

设 $f(i)$ 表示长度为 $i$ 的奇妙数组的数量。可以证明,对于任何固定的 $i \ge 2$,长度为 $i$ 的奇妙数组只有有限个。

给定一个整数 $n$。求 $f(2), f(3), \dots, f(n)$。由于这些数字可能非常大,请将它们对给定的质数 $P$ 取模后输出。

输入格式

输入的唯一一行包含两个整数 $n, P$($2 \le n \le 2 \cdot 10^5$,$10^8 \le P \le 10^9$,$P$ 为质数)。

输出格式

输出 $n - 1$ 个整数,即 $f(2), f(3), \dots, f(n)$ 对 $P$ 取模后的值。

样例

输入样例 1

7 804437957

输出样例 1

1 6 12 40 30 84

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.