Submission #442056

#TimeUsernameProblemLanguageResultExecution timeMemory
442056JovanBKangaroo (CEOI16_kangaroo)C++17
100 / 100
40 ms16044 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; const int MOD = 1000000007; int add(int a, int b){ a += b; if(a >= MOD) a -= MOD; return a; } int mul(int a, int b){ return (1LL*a*b)%MOD; } int dp[2005][2005]; int main(){ ios_base::sync_with_stdio(false), cin.tie(0); cout.precision(10); cout << fixed; 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][j], add(dp[i-1][j-1], dp[i-1][j])); else{ dp[i][j] = add(dp[i][j], mul(j, dp[i-1][j+1])); int mesta = j; if(i > a) mesta--; if(i > b) mesta--; dp[i][j] = add(dp[i][j], mul(mesta, dp[i-1][j-1])); } } } cout << dp[n][1] << "\n"; 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...