#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
const long long MX=3300;
long long dp[MX][MX];
long long cntdp(long long n,long long m)
{
if(n<=0 || m<=0)
{
return 1;
}
if(dp[n][m])
{
return dp[n][m];
}
dp[n][m]=cntdp(n-1,m);
dp[n][m]=(cntdp(n-1,m-1)*4*m+dp[n][m])%MOD;
dp[n][m]=((cntdp(n-1,m-2)*(m*(m-1)/2))%MOD+dp[n][m])%MOD;
dp[n][m]=((cntdp(n-2,m-1)*m*(n-1))%MOD+dp[n][m])%MOD;
return dp[n][m];
}
int main()
{
cin.tie(0);
ios_base::sync_with_stdio(0);
long long n,m;
cin>>n>>m;
cout<<(cntdp(n,m)-1+MOD)%MOD<<"\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
2140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
604 KB |
Output is correct |
6 |
Correct |
1 ms |
1372 KB |
Output is correct |
7 |
Correct |
1 ms |
860 KB |
Output is correct |
8 |
Correct |
1 ms |
1372 KB |
Output is correct |
9 |
Correct |
1 ms |
860 KB |
Output is correct |
10 |
Correct |
2 ms |
1884 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
2 ms |
2140 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
4 ms |
9820 KB |
Output is correct |
15 |
Correct |
119 ms |
47680 KB |
Output is correct |
16 |
Correct |
2 ms |
1632 KB |
Output is correct |
17 |
Correct |
11 ms |
6960 KB |
Output is correct |
18 |
Correct |
25 ms |
13664 KB |
Output is correct |
19 |
Correct |
139 ms |
53356 KB |
Output is correct |
20 |
Correct |
93 ms |
42328 KB |
Output is correct |
21 |
Correct |
53 ms |
25444 KB |
Output is correct |
22 |
Correct |
61 ms |
30824 KB |
Output is correct |
23 |
Correct |
41 ms |
26720 KB |
Output is correct |
24 |
Correct |
174 ms |
62924 KB |
Output is correct |
25 |
Correct |
117 ms |
50084 KB |
Output is correct |
26 |
Correct |
141 ms |
57260 KB |
Output is correct |
27 |
Correct |
150 ms |
60764 KB |
Output is correct |