提交时间:2022-07-20 13:21:46
运行 ID: 53006
#include <bits/stdc++.h> using namespace std; const int mod = 1000000007; int n, m, k; int f[405][405][405]; // n, k, s int fw[5005]; int fpow(int x, int y) { int ans = 1; while (y) { if (y & 1) { ans = 1ll * ans * x % mod; } x = 1ll * x * x % mod; y >>= 1; } return ans; } int main() { freopen("math.in", "r", stdin); freopen("math.out", "w", stdout); scanf("%d%d%d", &n, &k, &m); for (int i = 1; i <= n; i++) { fw[i] = fpow(i, m); } for (int i = 1; i <= k; i++) { for (int l = 1; l <= n; l++) { int sum = 0; for (int j = l; j <= n; j++) { sum = (1ll * sum + f[i - 1][j][l] + fw[j]) % mod; f[i][j][l] = sum; // printf("%d ", f[i][j]); } } } int sum = 0; for (int i = 1; i <= n; i++) { (sum += f[k][n][i]) %= mod; } printf("%d\n", sum); return 0; }