# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
120125 | arman_ferdous | Asceticism (JOI18_asceticism) | C++17 | 134 ms | 150904 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;
using ll = long long;
const int N = 3e3+100;
const int MOD = 1e9+7;
ll dp[N][N];
ll DP(int n, int k) {
if(k > n) return 0;
if(k == 1 || k == n || n == 1) return 1;
if(dp[n][k] != -1) return dp[n][k];
dp[n][k] = ((ll)(n - k + 1) * DP(n - 1, k - 1) % MOD) + ((ll)k * DP(n - 1, k) % MOD);
if(dp[n][k] >= MOD) dp[n][k] -= MOD;
return dp[n][k];
}
int main() {
memset(dp, -1, sizeof dp);
int n, k; scanf("%d %d", &n, &k);
printf("%lld", DP(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... |