제출 #677506

#제출 시각아이디문제언어결과실행 시간메모리
677506stevancv캥거루 (CEOI16_kangaroo)C++14
6 / 100
1 ms340 KiB
#include <bits/stdc++.h> #define ll long long #define ld long double #define sp ' ' #define en '\n' #define smin(a, b) a = min(a, b) #define smax(a, b) a = max(a, b) using namespace std; const int N = 2e3 + 2; const int mod = 1e9 + 7; int dp[N][N]; int Add(int a, int b) { a += b; if (a >= mod) a -= mod; return a; } int Mul(int a, int b) { ll c = (ll) (a * b); c %= mod; return c; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n, a, b; cin >> n >> a >> b; dp[1][1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= n; j++) { if (i == a || i == b) { dp[i][j] = Add(dp[i - 1][j - 1], dp[i - 1][j]); continue; } dp[i][j] = Add(dp[i][j], Mul(j, dp[i - 1][j + 1])); int k = j - (i > a) - (i > b); dp[i][j] = Add(dp[i][j], Mul(k, dp[i - 1][j - 1])); } } cout << dp[n][1] << en; return 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...