#include <bits/stdc++.h>
using namespace std;
const int N = 3001, MOD = 1e9 + 7;
int n, m;
long long f[N][N];
long long calc(int i, int j) {
if (i <= 0 || j <= 0) return 1;
if (f[i][j] != -1) return f[i][j];
long long &res = (f[i][j] = 0);
(res += calc(i - 1, j)) %= MOD;
(res += calc(i - 1, j - 1) * 4 * j) %= MOD;
(res += calc(i - 1, j - 2) * j * (j - 1) / 2) %= MOD;
(res += calc(i - 2, j - 1) * (i - 1) * j) %= MOD;
return res;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
memset(f, -1, sizeof f);
cout << calc(n, m) - 1;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |