注册 登录
编程论坛 C++教室

[讨论]ZJU2284何解

leeco 发布于 2007-05-16 16:26, 800 次点击
http://acm.zju.edu.cn/show_problem.php?pid=2284
5 回复
#2
I喜欢c2007-05-16 17:40
哪有什么ZJU2284
#3
PcrazyC2007-05-16 17:42
他是问你题目怎么做
#4
PcrazyC2007-05-16 17:44
ZJU是浙江大学zhejiang university

2284是题目代号
#5
I喜欢c2007-05-16 17:53

Inversion Number

--------------------------------------------------------------------------------

Time limit: 1 Seconds Memory limit: 32768K
Total Submit: 842 Accepted Submit: 335

--------------------------------------------------------------------------------

Let { A1,A2,...,An } be a permutation of the set{ 1,2,..., n}. The inversion number of the permutation is the number of integer pairs (i,j) that satisfy 1<=i<j<=n and Ai>Aj.

Your task is to calculate how many n-permutations has an inversion number of k.


Input

The input consists of several test cases. Each test case contains two integers n(0<n<=20) and k(0<=k<=200), which are mentioned above. Input is terminated by n=m=0, which should not be proceeded.

Output

For each case of input output the number of n-permutations that has an inversion number of k in one line.

Sample Input

2 0
5 3
0 0

Sample Output

1
15


没怎么看懂题

#6
leeco2007-05-16 18:48
题目的大意是令 A1,A2,...,An为集合{ 1,2,..., n}的一个排列,这个排列的逆序数是满足1<=i<j<=n且Ai>Aj的整数对(i,j)的个数。
你的任务是计算逆序数为k的{ 1,2,..., n}的排列的个数。

例如

n=2,k=0时,这样的排列有1个
n=5,k=3时,这样的排列有15个
1