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.