# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
96902 | Kastanda | Kangaroo (CEOI16_kangaroo) | C++11 | 19 ms | 14336 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.
// I do it for the glory
#include<bits/stdc++.h>
using namespace std;
const int N = 2059, Mod = 1e9 + 7;
int dp[N][N];
int main()
{
int n, s, f;
scanf("%d%d%d", &n, &s, &f);
int cnt = 0; dp[0][0] = 1;
for (int i = 1; i <= n; cnt += (i == s || i == f), i++)
for (int j = 1; j <= i; j++)
{
if (i == s || i == f)
dp[i][j] = (dp[i - 1][j] + dp[i - 1][j - 1]) % Mod;
else
dp[i][j] = (1LL * dp[i - 1][j + 1] * j + 1LL * dp[i - 1][j - 1] * (j - cnt)) % Mod;
}
return !printf("%d\n", dp[n][1]);
}
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... |