#include <bits/stdc++.h>
using namespace std;
long long dp[3005][3005];
int main()
{
int n, m;
cin >> n >> m;
long long mod=1e9+7;
for (int i=0; i<=3000; i++)
dp[i][0]=dp[0][i]=1;
for (int i=1; i<=3000; i++)
{
for (int j=1; j<=3000; j++)
{
dp[i][j]+=dp[i-1][j];
dp[i][j]+=dp[i-1][j-1]*4*j;
if (j>=2)
dp[i][j]+=dp[i-1][j-2]*j*(j-1)/2;
if (i >= 2)
dp[i][j]+=dp[i-2][j-1]*(i-1)*j;
dp[i][j]%=mod;
}
}
cout << dp[n][m]-1;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
70996 KB |
Output is correct |
2 |
Correct |
84 ms |
70804 KB |
Output is correct |
3 |
Correct |
70 ms |
70992 KB |
Output is correct |
4 |
Correct |
69 ms |
70996 KB |
Output is correct |
5 |
Correct |
68 ms |
70992 KB |
Output is correct |
6 |
Correct |
70 ms |
70848 KB |
Output is correct |
7 |
Correct |
74 ms |
70852 KB |
Output is correct |
8 |
Correct |
72 ms |
70776 KB |
Output is correct |
9 |
Correct |
74 ms |
70996 KB |
Output is correct |
10 |
Correct |
72 ms |
70992 KB |
Output is correct |
11 |
Correct |
75 ms |
70776 KB |
Output is correct |
12 |
Correct |
74 ms |
70992 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
70996 KB |
Output is correct |
2 |
Correct |
84 ms |
70804 KB |
Output is correct |
3 |
Correct |
70 ms |
70992 KB |
Output is correct |
4 |
Correct |
69 ms |
70996 KB |
Output is correct |
5 |
Correct |
68 ms |
70992 KB |
Output is correct |
6 |
Correct |
70 ms |
70848 KB |
Output is correct |
7 |
Correct |
74 ms |
70852 KB |
Output is correct |
8 |
Correct |
72 ms |
70776 KB |
Output is correct |
9 |
Correct |
74 ms |
70996 KB |
Output is correct |
10 |
Correct |
72 ms |
70992 KB |
Output is correct |
11 |
Correct |
75 ms |
70776 KB |
Output is correct |
12 |
Correct |
74 ms |
70992 KB |
Output is correct |
13 |
Correct |
66 ms |
70992 KB |
Output is correct |
14 |
Correct |
72 ms |
70996 KB |
Output is correct |
15 |
Correct |
72 ms |
70992 KB |
Output is correct |
16 |
Correct |
72 ms |
70828 KB |
Output is correct |
17 |
Correct |
70 ms |
70996 KB |
Output is correct |
18 |
Correct |
72 ms |
70872 KB |
Output is correct |
19 |
Correct |
74 ms |
70996 KB |
Output is correct |
20 |
Correct |
70 ms |
70996 KB |
Output is correct |
21 |
Correct |
73 ms |
70932 KB |
Output is correct |
22 |
Correct |
74 ms |
71116 KB |
Output is correct |
23 |
Correct |
73 ms |
70868 KB |
Output is correct |
24 |
Correct |
72 ms |
70996 KB |
Output is correct |
25 |
Correct |
71 ms |
70996 KB |
Output is correct |
26 |
Correct |
66 ms |
70992 KB |
Output is correct |
27 |
Correct |
75 ms |
70980 KB |
Output is correct |