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>
#define fi first
#define se second
using namespace std;
const int N=350;
const int MOD=1e9+7;
long long choose[2*N+10][2*N+10];
long long dp[N+10][N+10][2];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin>>n;
for(int i=0;i<=2*n;i++)
{
choose[i][0]=1;
for(int j=1;j<=i;j++)
choose[i][j]=(choose[i-1][j]+choose[i-1][j-1])%MOD;
}
dp[0][0][0]=1;
for(int i=1;i<=n;i++)
{
for(int j=0;j<=n;j++)
{
for(int k=0;k<=j;k++)
{
if(k==i)
{
dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-k][0]*choose[j][k])%MOD;
dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-k][1]*choose[j][k])%MOD;
}
else
{
dp[i][j][0]=(dp[i][j][0]+dp[i-1][j-k][0]*choose[j][k])%MOD;
dp[i][j][1]=(dp[i][j][1]+dp[i-1][j-k][1]*choose[j][k])%MOD;
}
}
//cerr<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<"\n";
}
}
cout<<dp[n][n][1]<<"\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |