|
||||||||||
Problem D. PermutationTime Limit: 4000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 240 Accepted Submission(s): 89 Problem Description 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. Input The first line of the input contains an integer T , denoting the number of test cases. In each test case, there are two integers n, p in one line, denoting the length of permutations and the modulo. 1 ¡Ü T ¡Ü 10, 1 ¡Ü n ¡Ü 100, 10^9 < p < 1.1 ¡Á 10^9, only two cases¡¯ n > 50, p is a prime. Output 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. Sample Input
Sample Output
Source | ||||||||||
|