Problem D. Problem D. Permutation
时间限制 2000 ms
内存限制 512 MB
Define the value of a permutation of 1 . . . n as
n
∑|pi - i|
i=1
Given n, p, for every s = 0 . . . n^2-1, count the number of permutations of length n
whose value equals to s.
Output the answer modulo a prime p.
输入数据
输出数据
For each test case, output one line contains n^2 integer, denoting the number of permutations of length n whose value equals to s = 0 . . . n^2-1 modulo p.
样例输入
复制
4
4 1000000223
3 1000000321
2 1000000123
1 1000000447
样例输出
复制
1 0 3 0 7 0 9 0 4 0 0 0 0 0 0 0
1 0 2 0 3 0 0 0 0
1 0 1 0
1
$ Mathjax font initiator $