Inv
Time limit2sMemory limit512 MB
Count involutions of n elements with exactly k inversions and report the count modulo 2.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Bit manipulation
- Solved
- No attempts yet
Problem
A permutation on elements is an involution if for each . Your task is to compute the number of involutions on elements with inversions. The answer can be large, so print only the parity of this number.
Input
The first line contains two space-separated integers: (), the length of the involution, and (), the number of inversions.
Output
Print a single number ( or ): the number of involutions on elements with exactly inversions, taken modulo .
Hint
In the first sample, there are such involutions.