#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int N = 3010;
const int MOD = 1e9 + 7;
inline int add(int a, int b) {
if(a + b < MOD) return a + b;
return a + b - MOD;
}
inline int mult(int a, int b) {
return (ll) a * b % MOD;
}
inline int pot(int a, int b) {
int ret = 1;
for(; b; b /= 2, a = mult(a, a))
if(b & 1) ret = mult(ret, a);
return ret;
}
inline int inv(int a) {
return pot(a, MOD - 2);
}
int w, h;
int C[N][N], F[N][N];
int f(int a, int b) {
if(!a || !b) return 1;
if(F[a][b] != -1) return F[a][b];
return F[a][b] = add(mult(mult(4, a), f(a - 1, b - 1)), f(a, b - 1));
}
int c(int a, int b) {
if(a == b || !b) return 1;
if(C[a][b] != -1) return C[a][b];
return C[a][b] = add(c(a - 1, b), c(a - 1, b - 1));
}
int main() {
memset(C, -1, sizeof(C));
memset(F, -1, sizeof(F));
scanf("%d%d", &h, &w);
int ans = MOD - 1;
for(int n = 0; n <= w && h >= 2 * n; ++n) {
int v = c(w, n);
for(int i = 0; i < n; ++i) v = mult(v, c(h - 2 * i, 2));
int prod = 1;
for(int m = 0; m <= h && h >= 2 * n + m && w >= 2 * m + n; ++m) {
ans = add(ans, mult(v, mult(mult(c(h - 2 * n, m), prod), f(w - n - 2 * m, h - 2 * n - m))));
prod = mult(prod, c(w - n - 2 * m, 2));
}
}
printf("%d\n", ans);
return 0;
}
Compilation message
construction.cpp: In function 'int main()':
construction.cpp:51:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
51 | scanf("%d%d", &h, &w);
| ~~~~~^~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
71 ms |
144208 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
71 ms |
144208 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
71 ms |
144208 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |