uva 12034

        /*  比赛的名次的所有方案数 _________________________________________________________________________________

                                           #include <iostream>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
using namespace std;
#define fir first
#define sec second
#define pb(x) push_back(x)
#define mem(A, X) memset(A, X, sizeof A)
#define REP(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define rep(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))
#define foreach(e,x) for(__typeof(x.begin()) e=x.begin();e!=x.end();++e)
typedef long long LL;
typedef unsigned long long ull;
typedef pair<long,long> pll; LL T,n;
const LL mod=10056;
LL f[1000+10]; LL c[1005][1005];
const int maxn=1001;
const int MOD=10056;
void init() {
for(int i = 0; i <= maxn; i++) {
c[i][0] = c[i][i] = 1;
for(int j = 1; j < i; j++)
c[i][j] = (c[i-1][j] + c[i-1][j-1]) % MOD;
}
} int main()
{
freopen("in.txt","r",stdin); init();
mem(f,0); f[0]=1;
REP(n,1,1000)
REP(i,1,n) f[n]+=c[n][i]*f[n-i]%mod;
while(cin>>T)
{
REP(kase,1,T)
{
int n;
cin>>n;
cout<<"Case "<<kase<<": "<<f[n]%mod<<endl;
} }
return 0;
} /*
note : 运用子问题寻找递推关系。
debug : 组合数初始化的时候,牵扯到取模的时候不能用横向的递推关系,会导致出现0,
optimize:
*/
上一篇:Link Cut Tree学习笔记


下一篇:ServletContext获取项目真实路径