码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 2643

时间:2014-10-12 15:36:28      阅读:156      评论:0      收藏:0      [点我收藏+]

标签:blog   io   os   for   sp   div   on   log   amp   

(第二类斯特林数*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;
}

  

HDU 2643

标签:blog   io   os   for   sp   div   on   log   amp   

原文地址:http://www.cnblogs.com/jie-dcai/p/4020377.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!