#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=3003;
ll n,m,dp[N][N],mod=1e9+7;
main () {
cin>>n>>m;
for (int i=0; i<=max(n,m); i++)
dp[i][0]=dp[0][i]=1;
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++) {
if (1<=i) dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
if (1<=i && 1<=j) dp[i][j]=(dp[i][j]+j*dp[i-1][j-1]*4)%mod;
if (2<=i && 1<=j) dp[i][j]=(dp[i][j]+j*(i-1)*dp[i-2][j-1])%mod;
if (1<=i && 2<=j) dp[i][j]=(dp[i][j]+((j-1)*j/2)*dp[i-1][j-2])%mod;
}
cout<<(dp[n][m]-1+mod)%mod<<"\n";
}
Compilation message
tents.cpp:11:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
11 | main () {
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
1132 KB |
Output is correct |
5 |
Correct |
2 ms |
1516 KB |
Output is correct |
6 |
Correct |
2 ms |
1388 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
876 KB |
Output is correct |
10 |
Correct |
2 ms |
1772 KB |
Output is correct |
11 |
Correct |
1 ms |
1516 KB |
Output is correct |
12 |
Correct |
4 ms |
2284 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
364 KB |
Output is correct |
2 |
Correct |
1 ms |
1004 KB |
Output is correct |
3 |
Correct |
1 ms |
492 KB |
Output is correct |
4 |
Correct |
1 ms |
1132 KB |
Output is correct |
5 |
Correct |
2 ms |
1516 KB |
Output is correct |
6 |
Correct |
2 ms |
1388 KB |
Output is correct |
7 |
Correct |
2 ms |
1388 KB |
Output is correct |
8 |
Correct |
1 ms |
1516 KB |
Output is correct |
9 |
Correct |
1 ms |
876 KB |
Output is correct |
10 |
Correct |
2 ms |
1772 KB |
Output is correct |
11 |
Correct |
1 ms |
1516 KB |
Output is correct |
12 |
Correct |
4 ms |
2284 KB |
Output is correct |
13 |
Correct |
4 ms |
7788 KB |
Output is correct |
14 |
Correct |
5 ms |
9708 KB |
Output is correct |
15 |
Correct |
199 ms |
55348 KB |
Output is correct |
16 |
Correct |
15 ms |
9452 KB |
Output is correct |
17 |
Correct |
46 ms |
17388 KB |
Output is correct |
18 |
Correct |
58 ms |
17900 KB |
Output is correct |
19 |
Correct |
234 ms |
63084 KB |
Output is correct |
20 |
Correct |
191 ms |
50924 KB |
Output is correct |
21 |
Correct |
129 ms |
35564 KB |
Output is correct |
22 |
Correct |
119 ms |
35436 KB |
Output is correct |
23 |
Correct |
68 ms |
27116 KB |
Output is correct |
24 |
Correct |
319 ms |
70892 KB |
Output is correct |
25 |
Correct |
237 ms |
61180 KB |
Output is correct |
26 |
Correct |
270 ms |
66672 KB |
Output is correct |
27 |
Correct |
300 ms |
69228 KB |
Output is correct |