#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,dp[3005][3005],MOD=1e9+7;
int main()
{
ios_base::sync_with_stdio(0),cin.tie(0);
cin >> n >> m;
for(int i=0;i<=n;i++)dp[i][0]=1;
for(int i=0;i<=m;i++)dp[0][i]=1;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
dp[i][j]+=(dp[i-1][j-1]*(ll)4*j)%MOD;
dp[i][j]%=MOD;
if(j>=2)dp[i][j]+=(dp[i-1][j-2]*((ll)j*(j-1)/2))%MOD;
dp[i][j]%=MOD;
if(i>=2)dp[i][j]+=(dp[i-2][j-1]*(ll)(i-1)*j)%MOD;
dp[i][j]%=MOD;
dp[i][j]+=dp[i-1][j];
dp[i][j]%=MOD;
}
}
printf("%lld\n",(dp[n][m]-1+MOD)%MOD);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
708 KB |
Output is correct |
6 |
Correct |
2 ms |
1344 KB |
Output is correct |
7 |
Correct |
1 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
1348 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
2132 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
1108 KB |
Output is correct |
5 |
Correct |
1 ms |
708 KB |
Output is correct |
6 |
Correct |
2 ms |
1344 KB |
Output is correct |
7 |
Correct |
1 ms |
852 KB |
Output is correct |
8 |
Correct |
1 ms |
1348 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
3 ms |
1748 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
5 ms |
2132 KB |
Output is correct |
13 |
Correct |
1 ms |
328 KB |
Output is correct |
14 |
Correct |
5 ms |
9672 KB |
Output is correct |
15 |
Correct |
265 ms |
55180 KB |
Output is correct |
16 |
Correct |
17 ms |
4180 KB |
Output is correct |
17 |
Correct |
56 ms |
12736 KB |
Output is correct |
18 |
Correct |
68 ms |
16988 KB |
Output is correct |
19 |
Correct |
289 ms |
62920 KB |
Output is correct |
20 |
Correct |
252 ms |
50876 KB |
Output is correct |
21 |
Correct |
150 ms |
33804 KB |
Output is correct |
22 |
Correct |
147 ms |
35404 KB |
Output is correct |
23 |
Correct |
92 ms |
26988 KB |
Output is correct |
24 |
Correct |
392 ms |
70876 KB |
Output is correct |
25 |
Correct |
298 ms |
61260 KB |
Output is correct |
26 |
Correct |
359 ms |
66712 KB |
Output is correct |
27 |
Correct |
370 ms |
68944 KB |
Output is correct |