#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 4, MOD = 1e9 + 7;
int n, m, _dp[N][N];
int dp(int i, int j) {
if (i < 0 || j < 0)
return 0;
else if (!i || !j)
return 1;
else
return _dp[i][j];
}
int c(int k) {
return k * (k - 1) / 2;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
for (int i = 1; i < N; ++i) {
for (int j = 1; j < N; ++j) {
_dp[i][j] = dp(i, j - 1);
_dp[i][j] = (_dp[i][j] + 4ll * i * dp(i - 1, j - 1) % MOD) % MOD;
_dp[i][j] = (_dp[i][j] + 1ll * c(i) * dp(i - 2, j - 1) % MOD) % MOD;
_dp[i][j] = (_dp[i][j] + 1ll * i * (j - 1) * dp(i - 1, j - 2) % MOD) % MOD;
}
}
cin >> n >> m;
cout << (dp(n, m) + MOD - 1) % MOD;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
35692 KB |
Output is correct |
2 |
Correct |
130 ms |
35672 KB |
Output is correct |
3 |
Correct |
129 ms |
35712 KB |
Output is correct |
4 |
Correct |
130 ms |
35664 KB |
Output is correct |
5 |
Correct |
130 ms |
35724 KB |
Output is correct |
6 |
Correct |
130 ms |
35668 KB |
Output is correct |
7 |
Correct |
131 ms |
35712 KB |
Output is correct |
8 |
Correct |
130 ms |
35664 KB |
Output is correct |
9 |
Correct |
132 ms |
35928 KB |
Output is correct |
10 |
Correct |
130 ms |
35668 KB |
Output is correct |
11 |
Correct |
131 ms |
35700 KB |
Output is correct |
12 |
Correct |
130 ms |
35700 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
132 ms |
35692 KB |
Output is correct |
2 |
Correct |
130 ms |
35672 KB |
Output is correct |
3 |
Correct |
129 ms |
35712 KB |
Output is correct |
4 |
Correct |
130 ms |
35664 KB |
Output is correct |
5 |
Correct |
130 ms |
35724 KB |
Output is correct |
6 |
Correct |
130 ms |
35668 KB |
Output is correct |
7 |
Correct |
131 ms |
35712 KB |
Output is correct |
8 |
Correct |
130 ms |
35664 KB |
Output is correct |
9 |
Correct |
132 ms |
35928 KB |
Output is correct |
10 |
Correct |
130 ms |
35668 KB |
Output is correct |
11 |
Correct |
131 ms |
35700 KB |
Output is correct |
12 |
Correct |
130 ms |
35700 KB |
Output is correct |
13 |
Correct |
132 ms |
35664 KB |
Output is correct |
14 |
Correct |
130 ms |
35664 KB |
Output is correct |
15 |
Correct |
130 ms |
35668 KB |
Output is correct |
16 |
Correct |
131 ms |
36232 KB |
Output is correct |
17 |
Correct |
130 ms |
35668 KB |
Output is correct |
18 |
Correct |
130 ms |
35736 KB |
Output is correct |
19 |
Correct |
130 ms |
35704 KB |
Output is correct |
20 |
Correct |
132 ms |
36180 KB |
Output is correct |
21 |
Correct |
133 ms |
35668 KB |
Output is correct |
22 |
Correct |
129 ms |
35724 KB |
Output is correct |
23 |
Correct |
130 ms |
35712 KB |
Output is correct |
24 |
Correct |
130 ms |
35712 KB |
Output is correct |
25 |
Correct |
130 ms |
35668 KB |
Output is correct |
26 |
Correct |
130 ms |
35704 KB |
Output is correct |
27 |
Correct |
130 ms |
35948 KB |
Output is correct |