A sequence of different integers is called
a permutation of size if
for every .
For every permutation we define its inversions as pairs
of indices such that .
Your task is to count the number of permutations of size ,
having a given number of inversions.
Task
Write a program which:
reads from the standard input the size of the permutation and the
number of inversions,
counts the number of permutations of the given size and having
the given number of inversions,
writes the result to the standard output.
Input
The first and only line of input contains two integers
and (,
),
separated by a single space and representing the size of permutation
and the number of inversions we are interested in.
Output
The first and only line of output should contain
the remainder of the division of the number of the permutations
we are interested in by .
Example
For the input data:
3 2
the correct result is:
2
The permutations of size which have inversions are
and .
Task author: Krzysztof Diks.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.