#P8107. [Cnoi2021] 未来试题
[Cnoi2021] 未来试题
Background
In the duplicate-checking stage of Cnoi2021, Cirno found that in the distant future, a problem from the 2077 freshman contest of Earthworm Technology University (some unknown school from the outside world) unexpectedly had a similarity to a problem in this set.
Given a positive integer , when generating a uniformly random permutation of length , find the expected number of inversions in the permutation, and output the answer modulo . (2077-xidian-freshman-online Problem.D)
The answer is clearly .
As an arithmetic genius, Cirno saw it at a glance.
But there is no need to worry: colliding with a future problem does not count as a collision, so this problem appears before you.
Problem Description
You are given two positive integers .
For all , when generating a uniformly random permutation of length , compute the probability that the number of inversions in the permutation modulo has remainder . Output the answers modulo .
Input Format
One line containing two integers .
Output Format
One line containing integers separated by spaces. The -th integer represents the probability that the number of inversions in the permutation modulo has remainder .
4 5
166374059 166374059 457528662 748683265 457528662
Hint
Sample Explanation
| Number of inversions | Permutations |
|---|---|
| 0 | |
| 1 | |
| 2 | |
| 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 | |
| 5 | |
| 6 |
Constraints
For of the testdata, it is guaranteed that , .
Re-collected from XDUCPC 2021 Onsite Contest F.
Translated by ChatGPT 5