我这辈子是做不会递推题了
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
using namespace std;
const int maxn=
1000+
10;
int c[maxn][maxn];
int t,nn;
int ans[maxn];
const int mod=
10056;
void init()
{
memset(c,0,
sizeof(c));
c[0][
0]=
1;
for(
int n=
1;n<=
1000;n++
)
{
ans[n]=
0;
for(
int k=
1;k<=n;k++
)
{
c[n][k]=(c[n-
1][k]+c[n-
1][k-
1])%mod*k%mod;
//c[n][k]代表n匹马分k次到达,乘以k是为了区分是k里的那次
ans[n]=(ans[n]+c[n][k])%
mod;
}
}
}
int main()
{
init();
scanf("%d",&
t);
int Case=
0;
while(t--
)
{
scanf("%d",&
nn);
printf("Case %d: %d\n",++
Case,ans[nn]);
}
return 0;
}
转载于:https://www.cnblogs.com/Wangwanxiang/p/8413013.html
转载请注明原文地址: https://win8.8miu.com/read-1495889.html