Counting Phenomenal Arrays
Time limit2sMemory limit1024 MB
For each size i from 2 to n, count arrays of i positive integers whose product equals their sum, modulo a prime P.
- Level
Medium7 of 10
- Topics
- Math, Combinatorics, Number theory
- Solved
- No attempts yet
Statement
Call an array of positive integers phenomenal if the product of its elements equals the sum of its elements, that is, .
For example, is phenomenal because . is phenomenal because . However, is not phenomenal, since .
Let denote the number of phenomenal arrays of size . It can be shown that for any fixed , there are only finitely many phenomenal arrays of size .
You are given an integer . Find . Since these numbers can be very large, output each one modulo , where is a prime given in the input.
Input
The only line of the input contains two integers and (, , is prime).
Output
Output integers: the values modulo .