QOJ.ac

QOJ

実行時間制限: 2.0 s メモリ制限: 256 MB 満点: 100 ハック可能 ✓

#14101. Підрахунок феноменальних масивів

統計

Назвемо масив додатних цілих чисел $[a_1,a_2,\ldots,a_k]$ феноменальним, якщо добуток його елементів дорівнює їхній сумі (тобто якщо $a_1a_2\cdots a_k=a_1+a_2+\cdots+a_k$).

Наприклад, масив $[2,2]$ є феноменальним, оскільки $2\cdot2=2+2=4$, і $[3,1,2]$ є феноменальним, оскільки $3\cdot1\cdot2=3+1+2=6$, але масив $[2,3]$ не є феноменальним, бо $2\cdot3\ne2+3$.

Нехай $f(i)$ позначає кількість феноменальних масивів довжини $i$. Можна довести, що для кожного фіксованого $i\ge2$ існує лише скінченна кількість феноменальних масивів довжини $i$.

Дано ціле число $n$. Знайдіть $f(2),f(3),\ldots,f(n)$. Оскільки ці числа можуть бути дуже великими, виведіть їх за модулем $P$, де $P$ — задане просте число.

Вхідні дані

Єдиний рядок вхідних даних містить два цілі числа $n,P$ ($2\le n\le2\cdot10^5$, $10^8\le P\le10^9$, $P$ — просте).

Вихідні дані

Виведіть $n-1$ цілих чисел — значення $f(2),f(3),\ldots,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.