Submission #990941

#TimeUsernameProblemLanguageResultExecution timeMemory
990941vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
21 ms25688 KiB
#include<bits/stdc++.h> #define int long long #define _ ios::sync_with_stdio(0),cout.tie(0),cin.tie(0); using namespace std; const int N = 2001, M = 1e9 + 7; int n, a, b, i, j, dp[N][N]; signed main() {_ cin >> n >> a >> b; dp[1][1] = 1; for (i = 2; i <= n; i++) for (j = 1; j <= i; j++) if (i == a || i == b) dp[i][j] = (dp[i - 1][j - 1] + dp[i - 1][j]) % M; else dp[i][j] = (dp[i - 1][j + 1] * j + dp[i - 1][j - 1] * (j - (a < i) - (b < i))) % M; return cout << dp[n][1], 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...