#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3+10;
const long long mod = 1e9+7;
typedef long long ll;
ll dp[maxn][maxn];
int main(void)
{
int n, m;
cin >> n >> m;
for (int i = 0; i < maxn; i++)
dp[i][0] = dp[0][i] = 1LL;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
dp[i][j] = dp[i-1][j];
dp[i][j] = (dp[i][j] + (dp[i-1][j-1]*4LL*(ll)j))%mod;
if (j >= 2)
dp[i][j] = (dp[i][j] + (dp[i-1][j-2] * 1LL*(j*(j-1))/2))%mod;
if (i >= 2)
dp[i][j] = (dp[i][j] + (dp[i-2][j-1] * 1LL*(j*(i-1))))%mod;
}
}
cout << dp[n][m]-1LL << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12544 KB |
Output is correct |
2 |
Correct |
11 ms |
12544 KB |
Output is correct |
3 |
Correct |
12 ms |
12544 KB |
Output is correct |
4 |
Correct |
8 ms |
12544 KB |
Output is correct |
5 |
Correct |
12 ms |
12672 KB |
Output is correct |
6 |
Correct |
11 ms |
12672 KB |
Output is correct |
7 |
Correct |
12 ms |
12800 KB |
Output is correct |
8 |
Correct |
12 ms |
12672 KB |
Output is correct |
9 |
Correct |
11 ms |
12544 KB |
Output is correct |
10 |
Correct |
12 ms |
12800 KB |
Output is correct |
11 |
Correct |
11 ms |
12544 KB |
Output is correct |
12 |
Correct |
13 ms |
13184 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
12544 KB |
Output is correct |
2 |
Correct |
11 ms |
12544 KB |
Output is correct |
3 |
Correct |
12 ms |
12544 KB |
Output is correct |
4 |
Correct |
8 ms |
12544 KB |
Output is correct |
5 |
Correct |
12 ms |
12672 KB |
Output is correct |
6 |
Correct |
11 ms |
12672 KB |
Output is correct |
7 |
Correct |
12 ms |
12800 KB |
Output is correct |
8 |
Correct |
12 ms |
12672 KB |
Output is correct |
9 |
Correct |
11 ms |
12544 KB |
Output is correct |
10 |
Correct |
12 ms |
12800 KB |
Output is correct |
11 |
Correct |
11 ms |
12544 KB |
Output is correct |
12 |
Correct |
13 ms |
13184 KB |
Output is correct |
13 |
Correct |
10 ms |
12544 KB |
Output is correct |
14 |
Correct |
10 ms |
12544 KB |
Output is correct |
15 |
Correct |
81 ms |
56184 KB |
Output is correct |
16 |
Correct |
16 ms |
15360 KB |
Output is correct |
17 |
Correct |
29 ms |
22272 KB |
Output is correct |
18 |
Correct |
38 ms |
24568 KB |
Output is correct |
19 |
Correct |
98 ms |
63340 KB |
Output is correct |
20 |
Correct |
85 ms |
53240 KB |
Output is correct |
21 |
Correct |
61 ms |
39288 KB |
Output is correct |
22 |
Correct |
52 ms |
38904 KB |
Output is correct |
23 |
Correct |
39 ms |
27128 KB |
Output is correct |
24 |
Correct |
125 ms |
71036 KB |
Output is correct |
25 |
Correct |
91 ms |
63096 KB |
Output is correct |
26 |
Correct |
109 ms |
67576 KB |
Output is correct |
27 |
Correct |
117 ms |
69524 KB |
Output is correct |