# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
528796 | LucaDantas | Asceticism (JOI18_asceticism) | C++17 | 44 ms | 24912 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;
constexpr int maxn = 3e3 + 10, mod = 1000000007;
int dp[maxn][maxn];
int main() {
int n, k; scanf("%d %d", &n, &k);
dp[1][0] = 1; --k; // já gasto um dia naturalmente que não conta
for(int i = 1; i <= n; i++) {
for(int down = 0; down <= k; down++) {
// printf("(%d %d -> %d) ", i, down, dp[i][down]);
dp[i+1][down+1] += 1ll * (i - down) * dp[i][down] % mod;
if(dp[i+1][down+1] >= mod) dp[i+1][down+1] -= mod;
dp[i+1][down] += 1ll * (down + 1) * dp[i][down] % mod;
if(dp[i+1][down] >= mod) dp[i+1][down] -= mod;
}
// puts("");
}
printf("%d\n", dp[n][k]);
}
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... |