当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

4243: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. For example, if P is the permutation:
    |1 2 3 4 5 6 7 8|
    |3 2 5 4 1 7 8 6|
we have:
  P(1) = 3
  P(P(1)) = P(3) = 5
and
  P(P(P(1))) = P(5) = 1
so the maximum in the cycle of 1 is 5.

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 <= P <= 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 <= n <= 20), and the third value is the desired maximum in the cycle of 1, k where (1 <= k <= 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.
输入样例
4
1 4 1
2 7 3
3 10 5
4 20 7
输出样例
1 6
2 168
3 86400
4 11585247657984000
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-4243

最后修改于 2020-10-25T23:11:41+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 32768/32768K(Java/Others)