/ OPS / 题库 /

Maximum in the Cycle of 1

Maximum in the Cycle of 1

#描述#
If p is a permutation of the integers 1, ..., n, the maximum in the cycle of 1 is the maximum of the values P(1), P(P(1)), P(P(P(1))), etc.</br >
For example, if P is the permutation:</br >
<center>|1 2 3 4 5 6 7 8|</center>
<center>|3 2 5 4 1 7 8 6|</center>
we have:</br >
P(1) = 3</br >
P(P(1)) = P(3) = 5</br >
and</br >
P(P(P(1))) = P(5) = 1</br >
so the maximum in the cycle of 1 is 5.</br >
For this problem, you will write a program which takes as input integers n, (n > 0) and k (1 <= k <= n), and returns the number of permutations of the integers 1, …, n, for which the maximum in the cycle of 1 is k.

#格式#
##输入格式##
The first line of input contains a single integer P, (1 &lt= P &lt= 1000), which is the number of data sets that follow. Each data set is a single line that contains the three space separated decimal integer values. The first value is the data set number, N. The second value is the size of the permutation, n where (1 &lt= n &lt= 20), and the third value is the desired maximum in the cycle of 1, k where (1 &lt= k &lt= n).

##输出格式##
For each data set there is one line of output. It contains the data set number (N) followed by a single space, followed by a double precision floating point whole value which is the number of permutations of the integers 1, …, n, for which the maximum in the cycle of 1 is k.

#样例1#
##样例输入1##

4
1 4 1
2 7 3
3 10 5
4 20 7

##样例输出1##

1 6
2 168
3 86400
4 11585247657984000

#限制#
1000ms
32768KB

#提示#

#来源#

信息

ID
1977
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者