#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define MOD 1000000007
LLI dp[3001][3001];
int main() {
int N,K;
cin >> N >> K;
K--;
int i,j;
dp[1][0] = 1;
for (i = 2; i <= N; i++) {
dp[i][0] = 1;
for (j = 1; j <= K; j++) dp[i][j] = (dp[i-1][j-1]*(i-j)+dp[i-1][j]*(j+1)) % MOD;
}
cout << dp[N][K] << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
4 ms |
1784 KB |
Output is correct |
15 |
Correct |
4 ms |
2296 KB |
Output is correct |
16 |
Correct |
4 ms |
2172 KB |
Output is correct |
17 |
Correct |
3 ms |
1144 KB |
Output is correct |
18 |
Correct |
3 ms |
1656 KB |
Output is correct |
19 |
Correct |
3 ms |
1016 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
4 ms |
1784 KB |
Output is correct |
15 |
Correct |
4 ms |
2296 KB |
Output is correct |
16 |
Correct |
4 ms |
2172 KB |
Output is correct |
17 |
Correct |
3 ms |
1144 KB |
Output is correct |
18 |
Correct |
3 ms |
1656 KB |
Output is correct |
19 |
Correct |
3 ms |
1016 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
4344 KB |
Output is correct |
22 |
Correct |
5 ms |
4344 KB |
Output is correct |
23 |
Correct |
9 ms |
7928 KB |
Output is correct |
24 |
Correct |
9 ms |
8312 KB |
Output is correct |
25 |
Correct |
13 ms |
11768 KB |
Output is correct |
26 |
Correct |
14 ms |
12180 KB |
Output is correct |
27 |
Correct |
13 ms |
12152 KB |
Output is correct |
28 |
Correct |
7 ms |
5240 KB |
Output is correct |
29 |
Correct |
3 ms |
1272 KB |
Output is correct |
30 |
Correct |
13 ms |
11768 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
380 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
376 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
11 |
Correct |
3 ms |
760 KB |
Output is correct |
12 |
Correct |
3 ms |
1528 KB |
Output is correct |
13 |
Correct |
3 ms |
1528 KB |
Output is correct |
14 |
Correct |
4 ms |
1784 KB |
Output is correct |
15 |
Correct |
4 ms |
2296 KB |
Output is correct |
16 |
Correct |
4 ms |
2172 KB |
Output is correct |
17 |
Correct |
3 ms |
1144 KB |
Output is correct |
18 |
Correct |
3 ms |
1656 KB |
Output is correct |
19 |
Correct |
3 ms |
1016 KB |
Output is correct |
20 |
Correct |
3 ms |
376 KB |
Output is correct |
21 |
Correct |
5 ms |
4344 KB |
Output is correct |
22 |
Correct |
5 ms |
4344 KB |
Output is correct |
23 |
Correct |
9 ms |
7928 KB |
Output is correct |
24 |
Correct |
9 ms |
8312 KB |
Output is correct |
25 |
Correct |
13 ms |
11768 KB |
Output is correct |
26 |
Correct |
14 ms |
12180 KB |
Output is correct |
27 |
Correct |
13 ms |
12152 KB |
Output is correct |
28 |
Correct |
7 ms |
5240 KB |
Output is correct |
29 |
Correct |
3 ms |
1272 KB |
Output is correct |
30 |
Correct |
13 ms |
11768 KB |
Output is correct |
31 |
Runtime error |
69 ms |
24824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |