# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
48228 | lovemathboy | Asceticism (JOI18_asceticism) | C++14 | 1104 ms | 262144 KiB |
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;
vector<vector<long long> > memo;
long long mod = 1000000007;
int n, k;
int main() {
scanf("%d %d", &n, &k); k--;
memo.resize(n+1);
for (int i = 0; i <= n; i++) {
memo[i].resize(k+1);
}
for (int i = 1; i <= n; i++) {
if (i <= k) memo[1][i] = 0;
memo[i][0] = 1;
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= k; j++) {
memo[i][j] = (memo[i-1][j] * (j + 1) + memo[i-1][j-1] * (i - j)) % mod;
}
}
printf("%lld\n", memo[n][k]);
return 0;
}
Compilation message (stderr)
# | 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... |