/**
____ ____ ____ ____ ____
||a |||t |||o |||d |||o ||
||__|||__|||__|||__|||__||
|/__\|/__\|/__\|/__\|/__\|
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N_MAX = 3002;
const int MOD = 1e9+7;
int n, k;
int dp[N_MAX][N_MAX];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> k;
dp[1][0] = 1;
for(int i = 2; i <= n; i++)
for(int j = 0; j < i; j++)
{
dp[i][j] = 1LL * dp[i - 1][j] * (j + 1) % MOD + 1LL * dp[i - 1][j - 1] * (i - j) % MOD;
if(dp[i][j] >= MOD)
dp[i][j] -= MOD;
}
cout << dp[n][k - 1] << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1664 KB |
Output is correct |
13 |
Correct |
1 ms |
1664 KB |
Output is correct |
14 |
Correct |
1 ms |
1664 KB |
Output is correct |
15 |
Correct |
1 ms |
1664 KB |
Output is correct |
16 |
Correct |
1 ms |
1664 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1664 KB |
Output is correct |
13 |
Correct |
1 ms |
1664 KB |
Output is correct |
14 |
Correct |
1 ms |
1664 KB |
Output is correct |
15 |
Correct |
1 ms |
1664 KB |
Output is correct |
16 |
Correct |
1 ms |
1664 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
6 ms |
6272 KB |
Output is correct |
22 |
Correct |
7 ms |
6272 KB |
Output is correct |
23 |
Correct |
6 ms |
6272 KB |
Output is correct |
24 |
Correct |
6 ms |
6272 KB |
Output is correct |
25 |
Correct |
6 ms |
6272 KB |
Output is correct |
26 |
Correct |
6 ms |
6272 KB |
Output is correct |
27 |
Correct |
6 ms |
6272 KB |
Output is correct |
28 |
Correct |
3 ms |
3456 KB |
Output is correct |
29 |
Correct |
1 ms |
1152 KB |
Output is correct |
30 |
Correct |
6 ms |
6272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
0 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
416 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1664 KB |
Output is correct |
13 |
Correct |
1 ms |
1664 KB |
Output is correct |
14 |
Correct |
1 ms |
1664 KB |
Output is correct |
15 |
Correct |
1 ms |
1664 KB |
Output is correct |
16 |
Correct |
1 ms |
1664 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
1 ms |
1536 KB |
Output is correct |
19 |
Correct |
1 ms |
896 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
6 ms |
6272 KB |
Output is correct |
22 |
Correct |
7 ms |
6272 KB |
Output is correct |
23 |
Correct |
6 ms |
6272 KB |
Output is correct |
24 |
Correct |
6 ms |
6272 KB |
Output is correct |
25 |
Correct |
6 ms |
6272 KB |
Output is correct |
26 |
Correct |
6 ms |
6272 KB |
Output is correct |
27 |
Correct |
6 ms |
6272 KB |
Output is correct |
28 |
Correct |
3 ms |
3456 KB |
Output is correct |
29 |
Correct |
1 ms |
1152 KB |
Output is correct |
30 |
Correct |
6 ms |
6272 KB |
Output is correct |
31 |
Runtime error |
87 ms |
56568 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |