Difficulty Level: Easy

Submissions: 143 Accuracy:


Number of permutation with K inversions

Given an array, an inversion is defined as a pair a[i], a[j] such that a[i] > a[j] and i < j. We are given two numbers N and k, we need to tell how many permutation of first N number have exactly K inversion.

The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. The first line of each test case contains integers N and K.

Print the count of the number of permutations for the first N numbers which have exactly K inversions. Since the answer can be quite large print the answer modulo 109+7. Print the answer for each testcase in a new line.

1<= T <=100
1<= N, K <=100

3 1

Explanation :  
Total Permutation of first N number,
123, 132, 213, 231, 312, 321
Permutation with 1 inversion : 132 and 213

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Sujnesh Mishra
Author: sujnesh

Set Default Code

It is recommended to 'Compile & Test' your code before clicking 'Submit'!

Compilation/Execution Result:

Need help with your code? Please use, generate link and share the link here.