使用C++编写代码,找到具有K个逆序对的排列数量

使用C++编写代码,找到具有K个逆序对的排列数量

在数组中,如果 a[i] > a[j] 且 i

Input: N = 4, K = 1 Output: 3 Explanation: Permutation of the first N numbers in total : 1234, 1243, 1324 and 2134. With 1 inversion we have 1243, 1324 and 2134. Input : N = 3, K = 2 Output : 3 Explanation: Permutation of the first N numbers in total : 123, 132, 213, 231, 312, and 321 with 2 inversions we have 231, 312 and 321.登录后复制