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<iostream>
using namespace std;
long long d[3002][3002], n, m;
long long mod = 1000000007;
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
d[i][0] = 1;
d[i][1] = i*(i - 1) / 2 + 4 * i + 1;
}
for (int i = 1; i <= m; i++)
{
d[0][i] = 1;
d[1][i] = i*(i - 1) / 2 + 4 * i + 1;
}
cout << 11 << endl;
for (long long i = 2; i <= n; i++)
{
for (long long j = 2; j <= m; j++)
{
d[i][j] = ((i*(i - 1) / 2) * d[i - 2][j - 1] + i * 4 * d[i - 1][j - 1] + i*(j - 1)*d[i - 1][j - 2] + d[i][j - 1]) % mod;
}
}
cout << (d[n][m] - 1 + mod) % mod << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |