Counting Phenomenal Arrays

면접 대비

시간 제한2초메모리 제한1024 MB

요약
원소들의 곱과 합이 같은 배열을 길이 2부터 n까지 각각 세어 소수로 나눈 나머지를 구한다.
난이도

어려움10점 중 8점

유형
조합론, 정수론, 수학
정답자
아직 제출이 없습니다

문제

Let's call an array \[a_1,a_2,…,a_k]\[a\_1, a\_2, \ldots, a\_k] of positive integers \textbf {phenomenal}, if the product of its elements is equal to the sum of its elements (i.e. if a_1a_2…a_k=a_1+a_2+…+a_ka\_1 a\_2 \ldots a\_k = a\_1 + a\_2 + \ldots + a\_k) .

For example, the array \[2,2]\[2, 2] is phenomenal, because 2⋅2=2+2=42\cdot 2 = 2+2 = 4, and \[3,1,2]\[3, 1, 2] is phenomenal, because 3⋅1⋅2=3+1+2=63\cdot 1 \cdot 2 = 3 + 1 + 2 = 6, but the array \[2,3]\[2, 3] is not phenomenal, as 2⋅3≠2+32\cdot 3 \neq 2+3.

Let f(i)f(i) denote the number of phenomenal arrays of size ii. It can be shown that for any fixed i≥2i \ge 2 there is only a finite number of phenomenal arrays of size ii.

You are given an integer nn. Find f(2),f(3),…,f(n)f(2), f(3), \ldots, f(n). As these numbers can be very big, output them modulo PP, where PP is a given prime number.

입력

The only line of the input contains two integers n,Pn, P (2≤n≤2⋅1052 \le n \le 2\cdot 10^5, 108≤P≤10910^8 \le P \le 10^9, PP is prime).

출력

Output n−1n-1 integers --- the values f(2),f(3),…,f(n)f(2), f(3), \ldots, f(n) modulo PP.

예제1

  1. 예제 1

    입력
    7 804437957
    
    예상 출력
    1 6 12 40 30 84