This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3003, K = N;
int n, k, dp[N][K];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> k;
dp[0][0] = 1;
for(int i = 1; i <= n; ++i) {
dp[i][0] = dp[i - 1][0];
for(int j = 1; j <= min(k, i - 1); ++j) {
dp[i][j] = (1ll * dp[i - 1][j - 1] * (i - j) + 1ll * dp[i - 1][j] * (j + 1)) % mod;
}
}
cout << dp[n][k - 1] << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |