//UVA12034Race
#include<cstdio>
#include<cstring>
const int maxn = 1000;
const int M = 10056;
int f[maxn + 5], c[maxn + 5][maxn + 5];
void Table_C() {
memset(c, 0, sizeof(c));
for(int i = 1; i <= maxn; i++) {
c[i][0] = 1; c[i][i] = 1;
for(int j = 1; j < i; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % M;
}
}
void Init() {
f[0] = 0; f[1] = 1; f[2] = 3; f[3] = 13;
for(int i = 4; i <= maxn; i++) {
for(int j = 1; j <= i; j++) {
f[i] = (f[i] + ((long long)c[i][j] * f[i - j]) % M) % M;//选j个作为第一名
}
f[i]++;
}
}
int main() {
Table_C();
Init();
int n, kase = 0, T;
//freopen("UVA12034out.txt", "w", stdout);
scanf("%d", &T);
while(T--) {
scanf("%d", &n);
printf("Case %d: %d\n", ++kase, f[n]);
}
}
/*
3
1
2
3
*/
UVA12034Race
最新推荐文章于 2019-04-29 13:34:38 发布