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

HDU 2512

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

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

水题

#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;
}

  

HDU 2512

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

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

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