Submission #909830

#TimeUsernameProblemLanguageResultExecution timeMemory
909830fanwenKangaroo (CEOI16_kangaroo)C++17
100 / 100
18 ms16056 KiB
#include <iostream> using namespace std; const int N = 2000 + 5; const int Mod = 1e9 + 7; int n, s, e, dp[N][N]; int main() { cin >> n >> s >> e; dp[0][0] = 1; for (int i = 1; i <= n; ++i) { for (int j = 1; j <= i; ++j) { if(i == s || i == e) { dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j]; } else { dp[i][j] = (1LL * dp[i - 1][j + 1] * j % Mod + 1LL * dp[i - 1][j - 1] * (j - (i > s) - (i > e)) % Mod); } if(dp[i][j] >= Mod) dp[i][j] -= Mod; } } cout << dp[n][1]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...