#P8107. Probability Distribution of Inversion Count Modulo k
Probability Distribution of Inversion Count Modulo k
Probability Distribution of Inversion Count Modulo k
You are given two positive integers n and k. Consider a random permutation of length n selected uniformly among all n! permutations. Let inv be the number of inversions in the permutation. For every integer i in the range \( [0, k) \), compute the probability that \( inv \mod k = i \). Since the answer can be very large, output these probabilities modulo \( 998244353 \).
In other words, if \( f(i) \) represents the number of permutations whose inversion count is congruent to \( i \) modulo \( k \), you need to compute \[ P(i) = f(i) \cdot (n!)^{-1} \mod 998244353,\] for every \( i \) from \( 0 \) to \( k-1 \).
Note: It is guaranteed that \( n! \) is invertible modulo \( 998244353 \).
inputFormat
The first and only line of the input contains two space-separated positive integers n and k.
\( 1 \leq n, k \leq 100 \) (you may assume small constraints for the purpose of this problem).
outputFormat
Output a single line containing \( k \) space-separated integers. The \( i^{th} \) integer (0-indexed) should be the probability that a random permutation of length n has an inversion count with remainder \( i \) when divided by k, computed modulo \( 998244353 \).
sample
3 3
332748118 332748118 332748118