# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
44942 | SpaimaCarpatilor | Asceticism (JOI18_asceticism) | C++17 | 98 ms | 56188 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;
int N, K, dp[3009][3009];
const int mod = 1e9 + 7;
int mul (int x, int y) {return 1LL * x * y % mod;}
void adto (int &x, int y) {x += y; if (x >= mod) x -= mod;}
int main ()
{
scanf ("%d %d", &N, &K);
dp[1][0] = 1;
for (int i=1; i<N; i++)
for (int j=0; j<i; j++)
{
adto (dp[i + 1][j], mul (j + 1, dp[i][j]));
adto (dp[i + 1][j + 1], mul (i - j, dp[i][j]));
}
printf ("%d\n", dp[N][K - 1]);
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... |