Submission #849728

#TimeUsernameProblemLanguageResultExecution timeMemory
849728justinlgl20Kangaroo (CEOI16_kangaroo)C++14
0 / 100
1 ms344 KiB
#include <bits/stdc++.h> using namespace std; #define int long long int dp[2005][2005]; const int MOD = 1000000007; int32_t main() { int n, start, end; cin >> n >> start >> end; dp[1][1] = 1; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == 1 and j == 1) dp[i][j] = 1; else if (i == 1) {dp[i][j] = 0; continue;} else if (i != start and i != end) { dp[i][j] = (int)(dp[i-1][j+1]*j)%MOD; int k = j; if (i > start) k -= 1; if (i > end) k -= 1; dp[i][j] += (int)(dp[i-1][j-1] * k)*MOD; } else { dp[i][j] = dp[i-1][j-1]; dp[i][j]%=MOD; dp[i][j] += dp[i-1][j]; dp[i][j]%=MOD; } } } cout << dp[n][1] << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...