A permutation is a sequence of numbers between 1 and such that each number appears exactly once. An inversion in a permutation is a pair of indices such that but . The weight of an inversion is .
How many permutations of elements exist where the sum of weights of all inversions is equal to ? For instance, there are exactly two such permutations for and : 3, 2, 1, 4 and 1, 4, 3, 2.
Input consists of several cases, each one with and . You can assume and .
For every case, print the number of permutations of elements such that the sum of weights of all inversions is .
Author: Petr Mitrichev
Generation: 2026-01-25T12:00:00.215Z
© Jutge.org, 2006–2026.
https://jutge.org