#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
//typedef complex<double> cpx;
#define fastio cin.tie(0)->sync_with_stdio(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define compress(x) x.erase(unique(all(x)),x.end())
#define ff first
#define ss second
#define INF 1e17
#define MAX 500010
#define SIZE 10010
#define MOD 1000000007
const ll mod = 1e9+7LL;
ll n,m,dp[3010][3010];
int main(){
fastio;
cin >> n >> m;
dp[0][0] = 1;
for(int i=1;i<=3000;i++){
dp[0][i] = 1;
dp[i][0] = 1;
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
dp[i][j] = dp[i-1][j];
dp[i][j] += 4*j*dp[i-1][j-1]; dp[i][j] %= mod;
if(j>=2) dp[i][j] += j*(j-1)/2*dp[i-1][j-2];
dp[i][j] %= mod;
if(i>=2) dp[i][j] += (i-1)*j*dp[i-2][j-1];
dp[i][j] %= mod;
}
}
cout << dp[n][m]-1;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
70512 KB |
Output is correct |
2 |
Correct |
10 ms |
70236 KB |
Output is correct |
3 |
Correct |
11 ms |
70236 KB |
Output is correct |
4 |
Correct |
10 ms |
70236 KB |
Output is correct |
5 |
Correct |
10 ms |
70256 KB |
Output is correct |
6 |
Correct |
10 ms |
70488 KB |
Output is correct |
7 |
Correct |
10 ms |
70236 KB |
Output is correct |
8 |
Correct |
11 ms |
70384 KB |
Output is correct |
9 |
Correct |
10 ms |
70196 KB |
Output is correct |
10 |
Correct |
11 ms |
70232 KB |
Output is correct |
11 |
Correct |
10 ms |
70236 KB |
Output is correct |
12 |
Correct |
12 ms |
70236 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
12 ms |
70512 KB |
Output is correct |
2 |
Correct |
10 ms |
70236 KB |
Output is correct |
3 |
Correct |
11 ms |
70236 KB |
Output is correct |
4 |
Correct |
10 ms |
70236 KB |
Output is correct |
5 |
Correct |
10 ms |
70256 KB |
Output is correct |
6 |
Correct |
10 ms |
70488 KB |
Output is correct |
7 |
Correct |
10 ms |
70236 KB |
Output is correct |
8 |
Correct |
11 ms |
70384 KB |
Output is correct |
9 |
Correct |
10 ms |
70196 KB |
Output is correct |
10 |
Correct |
11 ms |
70232 KB |
Output is correct |
11 |
Correct |
10 ms |
70236 KB |
Output is correct |
12 |
Correct |
12 ms |
70236 KB |
Output is correct |
13 |
Correct |
10 ms |
70232 KB |
Output is correct |
14 |
Correct |
11 ms |
70384 KB |
Output is correct |
15 |
Correct |
42 ms |
70500 KB |
Output is correct |
16 |
Correct |
12 ms |
70492 KB |
Output is correct |
17 |
Correct |
18 ms |
70492 KB |
Output is correct |
18 |
Correct |
21 ms |
70492 KB |
Output is correct |
19 |
Correct |
47 ms |
70492 KB |
Output is correct |
20 |
Correct |
47 ms |
70508 KB |
Output is correct |
21 |
Correct |
30 ms |
70492 KB |
Output is correct |
22 |
Correct |
31 ms |
70492 KB |
Output is correct |
23 |
Correct |
23 ms |
70484 KB |
Output is correct |
24 |
Correct |
61 ms |
71120 KB |
Output is correct |
25 |
Correct |
48 ms |
70492 KB |
Output is correct |
26 |
Correct |
61 ms |
70492 KB |
Output is correct |
27 |
Correct |
59 ms |
70488 KB |
Output is correct |