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.