hdu2049
来源:互联网 发布:java date setmonth 编辑:程序博客网 时间:2024/06/09 19:22
/*
Description:是2048的加强版
HDU__ACM 2049 不容易系列之(4)——考新郎
http://acm.hdu.edu.cn/showproblem.php?pid=2049
*/
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
using namespace std;
long long c[25];
void InitJc()
{
int i = 2;
c[0] = c[1] = 1;
for(; i <= 20; ++i)
c[i] = c[i-1]*i;
}
long long f(int n)
{
if(n == 1)
return 0;
if(n == 2)
return 1;
return (n-1)*( f(n-1) + f(n-2) );
}
int main()
{
int iCase;
int m, n;
long long s;
long long t ;
scanf("%d", &iCase);
InitJc();
while( iCase-- ){
scanf("%d%d", &n, &m);
s = f(m);/*m个完全错排的方法*/
t = c[n]/(c[n-m]*c[m]);
cout<<s*t<<endl;
}
///system("pause");
return 0;
}
本文出自 “东方快翔” 博客,请务必保留此出处http://hustluy.blog.51cto.com/1792080/607329
- hdu2049
- hdu2049
- hdu2049
- hdu2049
- HDU2049
- HDU2049
- HDU2049
- hdu2049
- HDU2049
- hdu2049
- HDU2049-递推式
- hdu2049(排列)
- hdu2049(新郞找新娘)
- hdu2049(组合数学)
- HDU2049错排问题
- HDU2049(51/600)
- hdu2049错排问题
- hdu2049 错排+组合问题
- hdu2048递推练习
- 单片机中大数据量处理:哈希表与跳表
- linux input输入子系统分析《四》:input子系统整体流程全面分析
- hdu2047
- hdu2044
- hdu2049
- POJACM3752
- 大数阶乘
- c语言中字符串处理函数
- scanf与gets函数读取字符串的区别
- 华中科技大学2010年复试上机题a+b
- 取石子游戏POJ1067
- POJ_1001 Exponentiation
- POJ_2593最大两不想交子段和问题