提交时间:2022-07-20 11:57:49
运行 ID: 52789
#include <bits/stdc++.h> using namespace std; inline int read(){ register int x(0); register short w(1); register char c(getchar()); for (;c < '0' || c > '9';c = getchar()) if (c == '-') w = -1; for (;c >= '0' && c <= '9';c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48); return x * w; } const int N(5010),Mod(1e9 + 7); int n,m,k;long long ans; long long s[N][N]; long long qp(long long a,int b){ long long ans(1); while (b){ if (b & 1) ans = ans * a % Mod; a = a * a % Mod; b >>= 1; } return ans; } int main(){ n = read(),k = read(),m = read();s[0][0] = 1; for (int i(1);i <= n;i++) for (int j(1);j <= i;j++) s[i][j] = (s[i - 1][j - 1] + s[i - j][j]) % Mod; // for (int i(1);i <= n;i++){ // for (int j(1);j <= n;j++) // cout << s[i][j] << " "; // cout << endl; // } for (int i(1);i <= n;i++){ int cur(qp(i,m)); for (int j(1);j <= k && n - i * j >= k - j;j++) ans = (ans + cur * 1ll * s[n - i * j][k - j]) % Mod; } cout << ans; return 0; }