# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1225399 | MarwenElarbi | Kangaroo (CEOI16_kangaroo) | C++17 | 1 ms | 832 KiB |
#include <bits/stdc++.h>
using namespace std;
const int nax=2e3+5;
const int MOD=1e9+7;
long long dp[nax][nax];
int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
#endif
int n,l,r;
cin>>n>>l>>r;
if(l>r) swap(l,r);
dp[0][0]=1;
for (int i = 1; i <= n; ++i)
{
for (int j = 0; j <= n-i+1; ++j)
{
if(j>0) dp[i][j]+=dp[i-1][j-1];
if(i<l){
dp[i][j]+=dp[i-1][j+1]*(j+1)*(j);
}else if(i==l){
dp[i][j]+=dp[i-1][j+1]*(j+1);
}else if(i<r){
dp[i][j]+=dp[i-1][j+1]*(j+1)*(j+1);
}else if(i==r){
dp[i][j]+=dp[i-1][j]*(j+1);
}else{
dp[i][j]+=dp[i-1][j+1]*(j+2)*(j+1);
}
//if(dp[i][j] > 0)cout << i << " "<<j<<" "<<dp[i][j]<<" "<<dp[i-1][j+1]<<endl;
dp[i][j]%=MOD;
}
}
cout <<dp[n-1][0]<<endl;
}
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... |