#include <bits/stdc++.h>
using namespace std;
const int N = 3e3 + 1;
typedef long long ll;
int n, k;
ll d[N][N], base = 1e9 + 7;
int main()
{
cin >> n >> k;
for (int i = 1; i <= n; ++i) d[i][0] = 1;
for (int i = 1; i <= n; ++i)
for (int j = 1; j < i; ++j)
d[i][j] = ((i - j)*d[i - 1][j - 1] + (j + 1)*(d[i - 1][j])) % base;
cout << d[n][k - 1];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
3 ms |
732 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
3 ms |
732 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
3 ms |
732 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
3 ms |
732 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
3 ms |
1148 KB |
Output is correct |
12 |
Correct |
4 ms |
2300 KB |
Output is correct |
13 |
Correct |
5 ms |
2320 KB |
Output is correct |
14 |
Correct |
5 ms |
2320 KB |
Output is correct |
15 |
Correct |
4 ms |
2368 KB |
Output is correct |
16 |
Correct |
5 ms |
2372 KB |
Output is correct |
17 |
Correct |
3 ms |
2372 KB |
Output is correct |
18 |
Correct |
4 ms |
2372 KB |
Output is correct |
19 |
Correct |
3 ms |
2372 KB |
Output is correct |
20 |
Correct |
3 ms |
2372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
3 ms |
732 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
3 ms |
732 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
3 ms |
1148 KB |
Output is correct |
12 |
Correct |
4 ms |
2300 KB |
Output is correct |
13 |
Correct |
5 ms |
2320 KB |
Output is correct |
14 |
Correct |
5 ms |
2320 KB |
Output is correct |
15 |
Correct |
4 ms |
2368 KB |
Output is correct |
16 |
Correct |
5 ms |
2372 KB |
Output is correct |
17 |
Correct |
3 ms |
2372 KB |
Output is correct |
18 |
Correct |
4 ms |
2372 KB |
Output is correct |
19 |
Correct |
3 ms |
2372 KB |
Output is correct |
20 |
Correct |
3 ms |
2372 KB |
Output is correct |
21 |
Correct |
15 ms |
8796 KB |
Output is correct |
22 |
Correct |
16 ms |
8816 KB |
Output is correct |
23 |
Correct |
17 ms |
8816 KB |
Output is correct |
24 |
Correct |
16 ms |
8816 KB |
Output is correct |
25 |
Correct |
16 ms |
8828 KB |
Output is correct |
26 |
Correct |
16 ms |
8828 KB |
Output is correct |
27 |
Correct |
15 ms |
8828 KB |
Output is correct |
28 |
Correct |
7 ms |
8828 KB |
Output is correct |
29 |
Correct |
3 ms |
8828 KB |
Output is correct |
30 |
Correct |
13 ms |
8828 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
592 KB |
Output is correct |
3 |
Correct |
2 ms |
592 KB |
Output is correct |
4 |
Correct |
2 ms |
592 KB |
Output is correct |
5 |
Correct |
2 ms |
620 KB |
Output is correct |
6 |
Correct |
3 ms |
620 KB |
Output is correct |
7 |
Correct |
3 ms |
732 KB |
Output is correct |
8 |
Correct |
3 ms |
732 KB |
Output is correct |
9 |
Correct |
3 ms |
732 KB |
Output is correct |
10 |
Correct |
2 ms |
744 KB |
Output is correct |
11 |
Correct |
3 ms |
1148 KB |
Output is correct |
12 |
Correct |
4 ms |
2300 KB |
Output is correct |
13 |
Correct |
5 ms |
2320 KB |
Output is correct |
14 |
Correct |
5 ms |
2320 KB |
Output is correct |
15 |
Correct |
4 ms |
2368 KB |
Output is correct |
16 |
Correct |
5 ms |
2372 KB |
Output is correct |
17 |
Correct |
3 ms |
2372 KB |
Output is correct |
18 |
Correct |
4 ms |
2372 KB |
Output is correct |
19 |
Correct |
3 ms |
2372 KB |
Output is correct |
20 |
Correct |
3 ms |
2372 KB |
Output is correct |
21 |
Correct |
15 ms |
8796 KB |
Output is correct |
22 |
Correct |
16 ms |
8816 KB |
Output is correct |
23 |
Correct |
17 ms |
8816 KB |
Output is correct |
24 |
Correct |
16 ms |
8816 KB |
Output is correct |
25 |
Correct |
16 ms |
8828 KB |
Output is correct |
26 |
Correct |
16 ms |
8828 KB |
Output is correct |
27 |
Correct |
15 ms |
8828 KB |
Output is correct |
28 |
Correct |
7 ms |
8828 KB |
Output is correct |
29 |
Correct |
3 ms |
8828 KB |
Output is correct |
30 |
Correct |
13 ms |
8828 KB |
Output is correct |
31 |
Runtime error |
58 ms |
25364 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |