首页 > 代码库 > HDU 2512

HDU 2512

水题

#include <iostream>#include <cstdio>#include <algorithm>#define LL __int64#define MOD 1000using 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