QOJ.ac

QOJ

Süre Sınırı: 2.0 s Bellek Sınırı: 256 MB Toplam puan: 100 Hack'lenebilir ✓

#14101. 驚異的な配列の数え上げ

İstatistikler

正整数の配列 $[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$ なので驚異的ではありません。

長さ $i$ の驚異的な配列の個数を $f(i)$ とします。任意の固定した $i\ge2$ に対し、長さ $i$ の驚異的な配列は有限個しかないことを示せます。

整数 $n$ が与えられます。$f(2),f(3),\ldots,f(n)$ を求めてください。これらの数は非常に大きくなることがあるため、与えられた素数 $P$ で割った余りを出力してください。

入力

入力は一行からなり、二つの整数 $n,P$($2\le n\le2\cdot10^5$、$10^8\le P\le10^9$、$P$ は素数)を含みます。

出力

$f(2),f(3),\ldots,f(n)$ をそれぞれ $P$ で割った余りを、$n-1$ 個の整数として出力してください。

入出力例

入力 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.