HDU 2512

水题

#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL __int64
#define MOD 1000
using namespace std;
LL str[2001][2001];
void initial(){
	for(LL i=0;i<=2000;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])%MOD)%MOD;
		printf("%I64d\n",ans);
	}
	return 0;
}

  

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