#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 3000 + 10;
const int mod = 1e9 + 7;
int dp[maxn][maxn];
int main(){
ios_base::sync_with_stdio(false);
int n, k;
cin >> n >> k;
dp[1][1] = 1;
for (int i = 1; i < n; i++){
for (int j = 1; j <= i; j++){
dp[i + 1][j] = (dp[i + 1][j] + 1ll * j * dp[i][j]) % mod;
dp[i + 1][j + 1] = (dp[i + 1][j + 1] + 1ll * (i - j + 1) * dp[i][j]) % mod;
}
}
cout << dp[n][k] << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
1664 KB |
Output is correct |
13 |
Correct |
3 ms |
1764 KB |
Output is correct |
14 |
Correct |
3 ms |
1792 KB |
Output is correct |
15 |
Correct |
4 ms |
1664 KB |
Output is correct |
16 |
Correct |
3 ms |
1664 KB |
Output is correct |
17 |
Correct |
3 ms |
1152 KB |
Output is correct |
18 |
Correct |
4 ms |
1536 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
1664 KB |
Output is correct |
13 |
Correct |
3 ms |
1764 KB |
Output is correct |
14 |
Correct |
3 ms |
1792 KB |
Output is correct |
15 |
Correct |
4 ms |
1664 KB |
Output is correct |
16 |
Correct |
3 ms |
1664 KB |
Output is correct |
17 |
Correct |
3 ms |
1152 KB |
Output is correct |
18 |
Correct |
4 ms |
1536 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
10 ms |
6400 KB |
Output is correct |
22 |
Correct |
10 ms |
6428 KB |
Output is correct |
23 |
Correct |
10 ms |
6256 KB |
Output is correct |
24 |
Correct |
10 ms |
6400 KB |
Output is correct |
25 |
Correct |
10 ms |
6400 KB |
Output is correct |
26 |
Correct |
11 ms |
6268 KB |
Output is correct |
27 |
Correct |
9 ms |
6272 KB |
Output is correct |
28 |
Correct |
6 ms |
3584 KB |
Output is correct |
29 |
Correct |
3 ms |
1152 KB |
Output is correct |
30 |
Correct |
10 ms |
6272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
2 ms |
768 KB |
Output is correct |
12 |
Correct |
3 ms |
1664 KB |
Output is correct |
13 |
Correct |
3 ms |
1764 KB |
Output is correct |
14 |
Correct |
3 ms |
1792 KB |
Output is correct |
15 |
Correct |
4 ms |
1664 KB |
Output is correct |
16 |
Correct |
3 ms |
1664 KB |
Output is correct |
17 |
Correct |
3 ms |
1152 KB |
Output is correct |
18 |
Correct |
4 ms |
1536 KB |
Output is correct |
19 |
Correct |
3 ms |
896 KB |
Output is correct |
20 |
Correct |
2 ms |
384 KB |
Output is correct |
21 |
Correct |
10 ms |
6400 KB |
Output is correct |
22 |
Correct |
10 ms |
6428 KB |
Output is correct |
23 |
Correct |
10 ms |
6256 KB |
Output is correct |
24 |
Correct |
10 ms |
6400 KB |
Output is correct |
25 |
Correct |
10 ms |
6400 KB |
Output is correct |
26 |
Correct |
11 ms |
6268 KB |
Output is correct |
27 |
Correct |
9 ms |
6272 KB |
Output is correct |
28 |
Correct |
6 ms |
3584 KB |
Output is correct |
29 |
Correct |
3 ms |
1152 KB |
Output is correct |
30 |
Correct |
10 ms |
6272 KB |
Output is correct |
31 |
Runtime error |
94 ms |
55996 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |