#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 |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
452 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
456 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
0 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
452 KB |
Output is correct |
8 |
Correct |
1 ms |
460 KB |
Output is correct |
9 |
Correct |
1 ms |
460 KB |
Output is correct |
10 |
Correct |
1 ms |
460 KB |
Output is correct |
11 |
Correct |
1 ms |
456 KB |
Output is correct |
12 |
Correct |
1 ms |
460 KB |
Output is correct |
13 |
Correct |
1 ms |
460 KB |
Output is correct |
14 |
Correct |
1 ms |
460 KB |
Output is correct |
15 |
Correct |
1 ms |
460 KB |
Output is correct |
16 |
Correct |
1 ms |
460 KB |
Output is correct |
17 |
Correct |
82 ms |
4668 KB |
Output is correct |
18 |
Correct |
2 ms |
972 KB |
Output is correct |
19 |
Correct |
19 ms |
2816 KB |
Output is correct |
20 |
Correct |
1 ms |
588 KB |
Output is correct |
21 |
Correct |
110 ms |
5156 KB |
Output is correct |
22 |
Correct |
13 ms |
2476 KB |
Output is correct |
23 |
Correct |
2 ms |
1100 KB |
Output is correct |
24 |
Correct |
25 ms |
3176 KB |
Output is correct |
25 |
Correct |
17 ms |
2764 KB |
Output is correct |
26 |
Correct |
32 ms |
3420 KB |
Output is correct |
27 |
Correct |
154 ms |
5784 KB |
Output is correct |
28 |
Correct |
156 ms |
5804 KB |
Output is correct |
29 |
Correct |
159 ms |
5788 KB |
Output is correct |
30 |
Correct |
170 ms |
5832 KB |
Output is correct |
31 |
Correct |
158 ms |
5864 KB |
Output is correct |
32 |
Correct |
161 ms |
5916 KB |
Output is correct |
33 |
Correct |
171 ms |
5908 KB |
Output is correct |
34 |
Correct |
166 ms |
5908 KB |
Output is correct |
35 |
Correct |
165 ms |
6020 KB |
Output is correct |
36 |
Correct |
171 ms |
5976 KB |
Output is correct |
37 |
Correct |
178 ms |
5952 KB |
Output is correct |