# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
491770 | shahriarkhan | Kangaroo (CEOI16_kangaroo) | C++14 | 27 ms | 22988 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 ;
const long long mod = 1e9 + 7 , mx = 2005 ;
long long dp[mx][mx] ;
int main()
{
int n , cs , cf ;
scanf("%d%d%d",&n,&cs,&cf) ;
dp[1][1] = 1 ;
int in = ((1==cf) || (1==cs)) ;
for(int i = 1 ; i < n ; ++i)
{
if(((i+1)==cf) || ((i+1)==cs)) ++in ;
for(int j = 1 ; j <= i ; ++j)
{
if(((i+1)==cs) || ((i+1)==cf))
{
dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j])%mod ;
dp[i+1][j] = (dp[i+1][j] + dp[i][j])%mod ;
}
else
{
dp[i+1][j+1] = (dp[i+1][j+1] + ((dp[i][j]*(j+1-in))%mod))%mod ;
dp[i+1][j-1] = (dp[i+1][j-1] + ((dp[i][j]*(j-1))%mod))%mod ;
}
}
}
printf("%lld\n",dp[n][1]) ;
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... |