HDU 2643

(第二类斯特林数*N的阶乘 )的和。

#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL __int64
#define MOD 20090126
using namespace std;
LL str[101][101];
LL con[101];
void initial(){
	con[0]=1;
	for(LL i=1;i<=100;i++)
	con[i]=(con[i-1]*i)%MOD;
	for(LL i=0;i<=100;i++){
		for(LL j=0;j<=i;j++){
			if(i==j) str[i][j]=1;
			else if(j==0&&i>=1) str[i][j]=0;
			else{
				str[i][j]=((j*str[i-1][j])%MOD+str[i-1][j-1])%MOD;
			}
		}
	}
}


int main(){
	initial();
	LL n,T;
	scanf("%I64d",&T);
	while(T--){
		scanf("%I64d",&n);
		LL ans=0;
		for(LL i=1;i<=n;i++)
		ans=(ans+(str[n][i]*con[i])%MOD)%MOD;
		printf("%I64d\n",ans);
	}
	return 0;
}

  

posted @ 2014-10-12 12:24  chenjunjie1994  阅读(210)  评论(0编辑  收藏  举报