atcoder#ARC140F. [ARC140F] ABS Permutation (Count ver.)
[ARC140F] ABS Permutation (Count ver.)
Score : points
Problem Statement
Find the number of permutations of that satisfy the following, modulo , for each .
- There are exactly integers such that and .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of permutations that satisfy the condition, modulo , for each .
3 1
0 4 2
- For , the condition is satisfied by no permutations .
- For , the condition is satisfied by four permutations : .
- For , the condition is satisfied by two permutations : .
4 3
12 12 0 0
10 5
1263360 1401600 710400 211200 38400 3840 0 0 0 0