QOJ.ac

QOJ

시간 제한: 2.0 s 메모리 제한: 256 MB 총점: 100 해킹 가능 ✓

#14101. Phänomenale Arrays zählen

통계

Ein Array positiver ganzer Zahlen $[a_1,a_2,\ldots,a_k]$ heißt phänomenal, wenn das Produkt seiner Elemente gleich ihrer Summe ist (also wenn $a_1a_2\cdots a_k=a_1+a_2+\cdots+a_k$).

Zum Beispiel ist das Array $[2,2]$ phänomenal, weil $2\cdot2=2+2=4$, und $[3,1,2]$ ist phänomenal, weil $3\cdot1\cdot2=3+1+2=6$, aber das Array $[2,3]$ ist nicht phänomenal, da $2\cdot3\ne2+3$.

Sei $f(i)$ die Anzahl phänomenaler Arrays der Länge $i$. Man kann zeigen, dass es für jedes feste $i\ge2$ nur endlich viele phänomenale Arrays der Länge $i$ gibt.

Gegeben ist eine ganze Zahl $n$. Bestimme $f(2),f(3),\ldots,f(n)$. Da diese Zahlen sehr groß sein können, gib sie modulo $P$ aus, wobei $P$ eine gegebene Primzahl ist.

Eingabe

Die einzige Eingabezeile enthält zwei ganze Zahlen $n,P$ ($2\le n\le2\cdot10^5$, $10^8\le P\le10^9$, $P$ ist eine Primzahl).

Ausgabe

Gib $n-1$ ganze Zahlen aus — die Werte $f(2),f(3),\ldots,f(n)$ modulo $P$.

Beispiele

Eingabe 1

7 804437957

Ausgabe 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.