标签:
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=2512
#include <cmath> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 2000; const int mod = 1000; #define met(a,b) memset(a,b,sizeof(a)) int bell[maxn+10],stirling[maxn+10][maxn+10]; void num() { met(bell,0); for(int i=1;i<=maxn;i++) { stirling[i][0]=0; stirling[i][i]=1; } stirling[0][0]=1; for(int i=1;i<=maxn;i++) for(int j=1;j<i;j++) stirling[i][j]=(stirling[i-1][j]*j+stirling[i-1][j-1])%mod; for(int i=1;i<=maxn;i++) for(int j=1;j<=i;j++) bell[i]=(bell[i]+stirling[i][j])%mod; } int main() { num(); int t; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); printf("%d\n",bell[n]); } }
标签:
原文地址:http://www.cnblogs.com/TAT1122/p/5866010.html