This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 3010;
const int MOD = 1e9+7;
ll n, m;
ll dp[N][N];
void add(ll &x, ll y) { x += y; if(x >= MOD) x -= MOD; }
ll DP(ll r, ll c) {
if(r <= 0 || c <= 0) return 1;
if(dp[r][c] != -1) return dp[r][c];
dp[r][c] = DP(r - 1, c);
add(dp[r][c], (4ll * c * DP(r - 1, c - 1) % MOD) );
add(dp[r][c], (((c * (c - 1)) >> 1) * DP(r - 1, c - 2) % MOD) );
add(dp[r][c], (c * (r - 1) * DP(r - 2, c - 1) % MOD) );
return dp[r][c];
}
int main() {
scanf("%lld %lld", &n, &m);
memset(dp, -1, sizeof dp);
printf("%lld\n", (DP(n, m) - 1 + MOD) % MOD);
return 0;
}
Compilation message (stderr)
tents.cpp: In function 'int main()':
tents.cpp:25:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld", &n, &m);
~~~~~^~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |