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

建议使用的浏览器:

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

3439:Sequence

题目描述
As you know, there number of permutation of the increasing vector {1, 2, 3…n} is exactly n! ;For example, if n = 3, then, {1,2,3} , {1,3,2}, {2,1,3}, {2,3,1}, {3,1,2}, {3,2,1} are all the permutation of the vector {1,2,3 };
  We define D( {A1,A2,…An} ) = the number of element that satisfy Ai=i
  For example, D( {1,2,3} ) = 3 ,D( {1,3,2} ) = 1 (only ‘1’ is at 1), D({3,1,2}) = 0 ….
  Now we want to calculate the number of permutation that satisfy D( {A1,A2,…An} ) = K.
  For example, if n = 3 and k = 3, then of course there is only one permutation {1,2,3} that satisfy D( {1,2,3}) = 3. But if n = 3 and k = 0, then there are two permutations {3,1,2} and {2,3,1} satisfy D( {3,2,1} ) = D( {2,3,1} ) = 0;
  But when n is very large, it’s hard to calculate by brute force algorithm. Optimal is one required here.
  Because the answer may be very large, so just output the remainder of the answer after divided by m.
输入解释
In the first line there is an integer T, indicates the number of test cases. (T <= 500)
In each case, the first line contains three integers n,k and m. (0 <= k<= n <=10^9, 1 <= m <= 10^5, n != 0)
输出解释
Output “Case %d: “first where d is the case number counted from one. Then output the remainder of the answer after divided by m.
输入样例
2

3 0 7

3 3 3
输出样例
Case 1: 2
Case 2: 1
来自杭电HDUOJ的附加信息
Author AekdyCoin
Recommend

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

源链接: HDU-3439

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

共提交 0

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