#P8107. [Cnoi2021] 未来试题

[Cnoi2021] 未来试题

Description

You are given two positive integers n,kn,k.

For all i[0,k)\forall i \in [0,k), when generating a uniformly random permutation of length nn, compute the probability that the number of inversions in the permutation modulo kk has remainder ii. Output the answers modulo 998244353998244353.

Input Format

One line containing two integers n,kn,k.

Output Format

One line containing kk integers separated by spaces. The ii-th integer represents the probability that the number of inversions in the permutation modulo kk has remainder i1i-1.

4 5
166374059 166374059 457528662 748683265 457528662

Hint

Sample Explanation

Number of inversions Permutations
0 (1,2,3,4)(1,2,3,4)
1 (1,2,4,3)(1,3,2,4)(2,1,3,4)(1,2,4,3)(1,3,2,4)(2,1,3,4)
2 (1,3,4,2)(1,4,2,3)(2,1,4,3)(2,3,1,4)(3,1,2,4)(1,3,4,2)(1,4,2,3)(2,1,4,3)(2,3,1,4)(3,1,2,4)
3 $(1,4,3,2)(2,3,4,1)(2,4,1,3)(3,1,4,2)(3,2,1,4)(4,1,2,3)$
4 (2,4,3,1)(3,2,4,1)(3,4,1,2)(4,1,3,2)(4,2,1,3)(2,4,3,1)(3,2,4,1)(3,4,1,2)(4,1,3,2)(4,2,1,3)
5 (3,4,2,1)(4,2,3,1)(4,3,1,2)(3,4,2,1)(4,2,3,1)(4,3,1,2)
6 (4,3,2,1)(4,3,2,1)

Constraints

For 100%100\% of the testdata, it is guaranteed that 1n1051\le n\le 10^5, 2k10002\le k\le 1000.

Re-collected from XDUCPC 2021 Onsite Contest F.

Translated by ChatGPT 5