1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| #include <bits/stdc++.h> #define rep(i, a, b) for(int i = (a); i <= (b); ++i) #define per(i, a, b) for(int i = (a); i >= (b); --i) #define debug(x) cerr << #x << ' ' << x << endl; using namespace std;
typedef long long ll; const int MOD = 9999973; const int MAXN = 2e5 + 7;
ll f[105][105][105]; ll C[105][105];
void init(){ C[0][0] = 1; rep(i, 1, 100){ rep(j, 0, i){ C[i][j] = C[i-1][j] + C[i-1][j-1]; } } } int main(int argc, char const *argv[]) { init(); int n, m; scanf("%d %d", &n, &m); f[0][0][0] = 1; rep(i, 1, n){ rep(j, 0, m){ rep(k, 0, m){ if(j + k > m) continue; f[i][j][k] += f[i-1][j][k]; f[i][j][k] %= MOD; f[i][j+1][k] += f[i-1][j][k] * (m - j - k); f[i][j+1][k] %= MOD; f[i][j-1][k+1] += f[i-1][j][k] * j; f[i][j-1][k+1] %= MOD; f[i][j+2][k] += f[i-1][j][k] * C[m - j - k][2]; f[i][j+2][k] %= MOD; f[i][j-2][k+2] += f[i-1][j][k] * C[j][2]; f[i][j-2][k+2] %= MOD; f[i][j][k+1] += f[i-1][j][k] * (m - j - k) * j; f[i][j][k+1] %= MOD; } } } ll ans = 0; rep(i, 0, m) rep(j, 0, m) { ans += f[n][i][j]; ans %= MOD; } printf("%lld\n", ans); return 0; }
|