#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long
#define ff first
#define ss second
#define N 3005
#define MOD 1000000007
#define INF 0x3f3f3f3f
ll dp[N][N];
ll c[N][N];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n, m;
cin>>n>>m;
for(int i = 0; i <= n; ++i)
dp[i][0] = 1;
for(int j = 0; j <= m; ++j)
dp[0][j] = 1;
for(int i = 1; i <= n; ++i)
for(int j = 1; j <= m; ++j)
dp[i][j] = (dp[i - 1][j] + (j >= 2 ? j * (j - 1) / 2 * dp[i - 1][j - 2] : 0) + 4 * j * dp[i - 1][j - 1] + (i >= 2 ? dp[i - 2][j - 1] * j * (i - 1) : 0)) % MOD;
cout<<(dp[n][m] + MOD - 1) % MOD;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
1144 KB |
Output is correct |
5 |
Correct |
5 ms |
760 KB |
Output is correct |
6 |
Correct |
5 ms |
1404 KB |
Output is correct |
7 |
Correct |
5 ms |
888 KB |
Output is correct |
8 |
Correct |
5 ms |
1528 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
6 ms |
1912 KB |
Output is correct |
11 |
Correct |
5 ms |
380 KB |
Output is correct |
12 |
Correct |
6 ms |
2296 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Correct |
5 ms |
380 KB |
Output is correct |
3 |
Correct |
5 ms |
504 KB |
Output is correct |
4 |
Correct |
5 ms |
1144 KB |
Output is correct |
5 |
Correct |
5 ms |
760 KB |
Output is correct |
6 |
Correct |
5 ms |
1404 KB |
Output is correct |
7 |
Correct |
5 ms |
888 KB |
Output is correct |
8 |
Correct |
5 ms |
1528 KB |
Output is correct |
9 |
Correct |
5 ms |
888 KB |
Output is correct |
10 |
Correct |
6 ms |
1912 KB |
Output is correct |
11 |
Correct |
5 ms |
380 KB |
Output is correct |
12 |
Correct |
6 ms |
2296 KB |
Output is correct |
13 |
Correct |
5 ms |
376 KB |
Output is correct |
14 |
Correct |
9 ms |
9720 KB |
Output is correct |
15 |
Correct |
49 ms |
55160 KB |
Output is correct |
16 |
Correct |
8 ms |
4088 KB |
Output is correct |
17 |
Correct |
16 ms |
12920 KB |
Output is correct |
18 |
Correct |
18 ms |
17144 KB |
Output is correct |
19 |
Correct |
55 ms |
62968 KB |
Output is correct |
20 |
Correct |
47 ms |
50936 KB |
Output is correct |
21 |
Correct |
32 ms |
33784 KB |
Output is correct |
22 |
Correct |
33 ms |
35448 KB |
Output is correct |
23 |
Correct |
24 ms |
27132 KB |
Output is correct |
24 |
Correct |
69 ms |
70904 KB |
Output is correct |
25 |
Correct |
56 ms |
61304 KB |
Output is correct |
26 |
Correct |
64 ms |
66680 KB |
Output is correct |
27 |
Correct |
66 ms |
69116 KB |
Output is correct |