#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL MOD = 1000000007;
int main(){
int n, k;
cin >> n >> k;
n--;
k--;
LL dp[n+1][n+1];
for(LL i = 0; i <= n; i++){
for(LL j = 0; j <= i; j++){
dp[i][j] = 0;
if(i == 0 && j == 0){
dp[i][j] = 1;
}
if(i > 0){
if(j > 0){
dp[i][j] += dp[i-1][j-1] * (i+1-j);
}
if(j < i){
dp[i][j] += dp[i-1][j] * (j+1);
}
}
dp[i][j] %= MOD;
}
}
cout << dp[n][k] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
2 ms |
756 KB |
Output is correct |
7 |
Correct |
2 ms |
756 KB |
Output is correct |
8 |
Correct |
2 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
2 ms |
756 KB |
Output is correct |
7 |
Correct |
2 ms |
756 KB |
Output is correct |
8 |
Correct |
2 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
788 KB |
Output is correct |
12 |
Correct |
2 ms |
1560 KB |
Output is correct |
13 |
Correct |
2 ms |
1560 KB |
Output is correct |
14 |
Correct |
2 ms |
1560 KB |
Output is correct |
15 |
Correct |
3 ms |
1560 KB |
Output is correct |
16 |
Correct |
3 ms |
1560 KB |
Output is correct |
17 |
Correct |
3 ms |
1560 KB |
Output is correct |
18 |
Correct |
2 ms |
1560 KB |
Output is correct |
19 |
Correct |
2 ms |
1560 KB |
Output is correct |
20 |
Correct |
2 ms |
1560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
2 ms |
756 KB |
Output is correct |
7 |
Correct |
2 ms |
756 KB |
Output is correct |
8 |
Correct |
2 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
788 KB |
Output is correct |
12 |
Correct |
2 ms |
1560 KB |
Output is correct |
13 |
Correct |
2 ms |
1560 KB |
Output is correct |
14 |
Correct |
2 ms |
1560 KB |
Output is correct |
15 |
Correct |
3 ms |
1560 KB |
Output is correct |
16 |
Correct |
3 ms |
1560 KB |
Output is correct |
17 |
Correct |
3 ms |
1560 KB |
Output is correct |
18 |
Correct |
2 ms |
1560 KB |
Output is correct |
19 |
Correct |
2 ms |
1560 KB |
Output is correct |
20 |
Correct |
2 ms |
1560 KB |
Output is correct |
21 |
Correct |
8 ms |
7800 KB |
Output is correct |
22 |
Correct |
8 ms |
7800 KB |
Output is correct |
23 |
Correct |
9 ms |
7800 KB |
Output is correct |
24 |
Correct |
9 ms |
7800 KB |
Output is correct |
25 |
Correct |
12 ms |
7800 KB |
Output is correct |
26 |
Correct |
11 ms |
7800 KB |
Output is correct |
27 |
Correct |
14 ms |
7800 KB |
Output is correct |
28 |
Correct |
7 ms |
7800 KB |
Output is correct |
29 |
Correct |
3 ms |
7800 KB |
Output is correct |
30 |
Correct |
11 ms |
7800 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
484 KB |
Output is correct |
3 |
Correct |
2 ms |
524 KB |
Output is correct |
4 |
Correct |
2 ms |
672 KB |
Output is correct |
5 |
Correct |
2 ms |
672 KB |
Output is correct |
6 |
Correct |
2 ms |
756 KB |
Output is correct |
7 |
Correct |
2 ms |
756 KB |
Output is correct |
8 |
Correct |
2 ms |
756 KB |
Output is correct |
9 |
Correct |
2 ms |
756 KB |
Output is correct |
10 |
Correct |
2 ms |
756 KB |
Output is correct |
11 |
Correct |
2 ms |
788 KB |
Output is correct |
12 |
Correct |
2 ms |
1560 KB |
Output is correct |
13 |
Correct |
2 ms |
1560 KB |
Output is correct |
14 |
Correct |
2 ms |
1560 KB |
Output is correct |
15 |
Correct |
3 ms |
1560 KB |
Output is correct |
16 |
Correct |
3 ms |
1560 KB |
Output is correct |
17 |
Correct |
3 ms |
1560 KB |
Output is correct |
18 |
Correct |
2 ms |
1560 KB |
Output is correct |
19 |
Correct |
2 ms |
1560 KB |
Output is correct |
20 |
Correct |
2 ms |
1560 KB |
Output is correct |
21 |
Correct |
8 ms |
7800 KB |
Output is correct |
22 |
Correct |
8 ms |
7800 KB |
Output is correct |
23 |
Correct |
9 ms |
7800 KB |
Output is correct |
24 |
Correct |
9 ms |
7800 KB |
Output is correct |
25 |
Correct |
12 ms |
7800 KB |
Output is correct |
26 |
Correct |
11 ms |
7800 KB |
Output is correct |
27 |
Correct |
14 ms |
7800 KB |
Output is correct |
28 |
Correct |
7 ms |
7800 KB |
Output is correct |
29 |
Correct |
3 ms |
7800 KB |
Output is correct |
30 |
Correct |
11 ms |
7800 KB |
Output is correct |
31 |
Runtime error |
3 ms |
7800 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |