Permutation deliveries

2.5

6 votes
Permutation and combination, Dynamic Programming, 2D dynamic programming, Fast Fourier transform, Advanced Algorithms, Algorithms, Divide-and-conquer algorithm
Problem

Consider that you are given a permutation p of length n.
Let us define parts(p) as the minimum size of a subset of {1,2,3,...,n} like s that for all i (1in), at least one of i or pi or ppi or pppior ... are in s.
For example, parts(1,2,3)=3 and parts(2,1,3)=2.

ِYou are given n for all i (1in) find number of permutations like p that parts(p)=i modular 998244353.

Input format

The only line of input contains an integer n.

1n5×105

Output format

Print a single line n space-separated integers denoting the answer of the problem.

Time Limit: 3.5
Memory Limit: 256
Source Limit:
Explanation

parts(1,2,3)=3
parts(1,3,2)=2
parts(2,1,3)=2
parts(3,2,1)=2
parts(2,3,1)=1
parts(3,1,2)=1

Editor Image

?