PERMUT1  Permutations
Let A = [a_{1}, a_{2}, ... a_{n}] be a permutation of integers 1, 2, ... n. A pair of indices (i, j), 1 <= i <= j <= n, is an inversion of the permutation A if a_{i} > a_{j}. We are given integers n > 0 and k >= 0. What is the number of nelement permutations containing exactly k inversions?
For instance, the number of 4element permutations with exactly 1 inversion equals 3.
Task
Write a program which for each data set from a sequence of several data sets:
 reads integers n and k from input,
 computes the number of nelement permutations with exactly k inversions,
 writes the result to output.
Input
The first line of the input file contains one integer d, 1 <= d <= 10, which is the number of data sets. The data sets follow. Each data set occupies one line of the input file and contains two integers n (1 <= n <= 12) and k (0 <= k <= 98) separated by a single space.
Output
The ith line of the output file should contain one integer  the number of nelement permutations with exactly k inversions.
Example
Input: 1 4 1 Output: 3
hide comments
vinupreethi93:
20200707 03:08:11
https://stackoverflow.com/questions/19372991/numberofnelementpermutationswithexactlykinversions 

santhosh_80:
20200505 03:26:45
A good question, can be solved using DP with bitmasking 

ekesh:
20200427 22:53:49
The input constraints are wrong. They test cases in which n > 12. I was able to solve the problem by assuming n <= 20. 

an09mous:
20200414 13:28:54
Very good question. I loved solving it. 

maskmanlucifer:
20200405 04:35:52
nice question for beginners. 

hellb0y_suru:
20200322 20:52:20
@taiken


whyamievenhere:
20181220 16:00:30
just ensure dp[1][0]==1 .. got 2 WA because of it.. 

salman3007:
20181026 20:18:35
one of the best problem i ever had on dp... 

be1035016:
20180628 15:32:34
good problem:)


sherlock11:
20180530 20:26:29
func(n,k)=summation func(n1,ki)...........and then AC:) 
Added by:  adrian 
Date:  20040622 
Time limit:  3s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All 
Resource:  III Polish Collegiate Team Programming Contest (AMPPZ), 1998 