# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
307653 | Elephant52 | Kangaroo (CEOI16_kangaroo) | C++11 | 63 ms | 31608 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vpi;
#define INF 1000000000
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (ll i = a; i < b; i++)
void setIO(string name) {
freopen((name+".in").c_str(), "r", stdin);
freopen((name+".out").c_str(), "w", stdout);
}
int N, A, B;
int mod = 1e9 + 7;
ll dp[2001][2001];
int main() {
ios::sync_with_stdio(0); cin.tie(0);
cin >> N >> A >> B;
dp[1][1] = 1;
rep(i,2,N+1) {
rep(j,1,N+1) {
if (i == A || i == B) dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]) % mod;
else dp[i][j] = j * dp[i-1][j+1] % mod + dp[i-1][j-1] * (j - (i > A) - (i > B)) % mod;
}
}
cout << dp[N][1] << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |