#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3010;
const int MOD = 1e9 + 7;
ll dp[MAXN][MAXN];
int N,K;
ll solve(int dia,int grupos){
if(dp[dia][grupos] != -1) return dp[dia][grupos];
if(grupos == 0) return dp[dia][grupos] = 0;
if(dia == 1) return dp[dia][grupos] = (grupos == 1);
return dp[dia][grupos] = ((grupos)*solve(dia - 1,grupos) + (dia - grupos + 1)*solve(dia - 1,grupos - 1)) % MOD;
}
int main(){
memset(dp,-1,sizeof(dp));
cin >> N >> K;
cout << solve(N,K) << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
71224 KB |
Output is correct |
2 |
Correct |
60 ms |
71280 KB |
Output is correct |
3 |
Correct |
64 ms |
71460 KB |
Output is correct |
4 |
Correct |
56 ms |
71496 KB |
Output is correct |
5 |
Correct |
57 ms |
71496 KB |
Output is correct |
6 |
Correct |
58 ms |
71560 KB |
Output is correct |
7 |
Correct |
54 ms |
71588 KB |
Output is correct |
8 |
Correct |
66 ms |
71588 KB |
Output is correct |
9 |
Correct |
65 ms |
71588 KB |
Output is correct |
10 |
Correct |
61 ms |
71664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
71224 KB |
Output is correct |
2 |
Correct |
60 ms |
71280 KB |
Output is correct |
3 |
Correct |
64 ms |
71460 KB |
Output is correct |
4 |
Correct |
56 ms |
71496 KB |
Output is correct |
5 |
Correct |
57 ms |
71496 KB |
Output is correct |
6 |
Correct |
58 ms |
71560 KB |
Output is correct |
7 |
Correct |
54 ms |
71588 KB |
Output is correct |
8 |
Correct |
66 ms |
71588 KB |
Output is correct |
9 |
Correct |
65 ms |
71588 KB |
Output is correct |
10 |
Correct |
61 ms |
71664 KB |
Output is correct |
11 |
Correct |
66 ms |
71668 KB |
Output is correct |
12 |
Correct |
58 ms |
71668 KB |
Output is correct |
13 |
Correct |
57 ms |
71676 KB |
Output is correct |
14 |
Correct |
62 ms |
71680 KB |
Output is correct |
15 |
Correct |
67 ms |
71684 KB |
Output is correct |
16 |
Correct |
59 ms |
71688 KB |
Output is correct |
17 |
Correct |
66 ms |
71688 KB |
Output is correct |
18 |
Correct |
60 ms |
71696 KB |
Output is correct |
19 |
Correct |
58 ms |
71700 KB |
Output is correct |
20 |
Correct |
60 ms |
71704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
71224 KB |
Output is correct |
2 |
Correct |
60 ms |
71280 KB |
Output is correct |
3 |
Correct |
64 ms |
71460 KB |
Output is correct |
4 |
Correct |
56 ms |
71496 KB |
Output is correct |
5 |
Correct |
57 ms |
71496 KB |
Output is correct |
6 |
Correct |
58 ms |
71560 KB |
Output is correct |
7 |
Correct |
54 ms |
71588 KB |
Output is correct |
8 |
Correct |
66 ms |
71588 KB |
Output is correct |
9 |
Correct |
65 ms |
71588 KB |
Output is correct |
10 |
Correct |
61 ms |
71664 KB |
Output is correct |
11 |
Correct |
66 ms |
71668 KB |
Output is correct |
12 |
Correct |
58 ms |
71668 KB |
Output is correct |
13 |
Correct |
57 ms |
71676 KB |
Output is correct |
14 |
Correct |
62 ms |
71680 KB |
Output is correct |
15 |
Correct |
67 ms |
71684 KB |
Output is correct |
16 |
Correct |
59 ms |
71688 KB |
Output is correct |
17 |
Correct |
66 ms |
71688 KB |
Output is correct |
18 |
Correct |
60 ms |
71696 KB |
Output is correct |
19 |
Correct |
58 ms |
71700 KB |
Output is correct |
20 |
Correct |
60 ms |
71704 KB |
Output is correct |
21 |
Correct |
69 ms |
71720 KB |
Output is correct |
22 |
Correct |
67 ms |
71720 KB |
Output is correct |
23 |
Correct |
72 ms |
71720 KB |
Output is correct |
24 |
Correct |
69 ms |
71720 KB |
Output is correct |
25 |
Correct |
70 ms |
71724 KB |
Output is correct |
26 |
Correct |
73 ms |
71728 KB |
Output is correct |
27 |
Correct |
80 ms |
71732 KB |
Output is correct |
28 |
Correct |
60 ms |
71736 KB |
Output is correct |
29 |
Correct |
70 ms |
71736 KB |
Output is correct |
30 |
Correct |
66 ms |
71748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
71224 KB |
Output is correct |
2 |
Correct |
60 ms |
71280 KB |
Output is correct |
3 |
Correct |
64 ms |
71460 KB |
Output is correct |
4 |
Correct |
56 ms |
71496 KB |
Output is correct |
5 |
Correct |
57 ms |
71496 KB |
Output is correct |
6 |
Correct |
58 ms |
71560 KB |
Output is correct |
7 |
Correct |
54 ms |
71588 KB |
Output is correct |
8 |
Correct |
66 ms |
71588 KB |
Output is correct |
9 |
Correct |
65 ms |
71588 KB |
Output is correct |
10 |
Correct |
61 ms |
71664 KB |
Output is correct |
11 |
Correct |
66 ms |
71668 KB |
Output is correct |
12 |
Correct |
58 ms |
71668 KB |
Output is correct |
13 |
Correct |
57 ms |
71676 KB |
Output is correct |
14 |
Correct |
62 ms |
71680 KB |
Output is correct |
15 |
Correct |
67 ms |
71684 KB |
Output is correct |
16 |
Correct |
59 ms |
71688 KB |
Output is correct |
17 |
Correct |
66 ms |
71688 KB |
Output is correct |
18 |
Correct |
60 ms |
71696 KB |
Output is correct |
19 |
Correct |
58 ms |
71700 KB |
Output is correct |
20 |
Correct |
60 ms |
71704 KB |
Output is correct |
21 |
Correct |
69 ms |
71720 KB |
Output is correct |
22 |
Correct |
67 ms |
71720 KB |
Output is correct |
23 |
Correct |
72 ms |
71720 KB |
Output is correct |
24 |
Correct |
69 ms |
71720 KB |
Output is correct |
25 |
Correct |
70 ms |
71724 KB |
Output is correct |
26 |
Correct |
73 ms |
71728 KB |
Output is correct |
27 |
Correct |
80 ms |
71732 KB |
Output is correct |
28 |
Correct |
60 ms |
71736 KB |
Output is correct |
29 |
Correct |
70 ms |
71736 KB |
Output is correct |
30 |
Correct |
66 ms |
71748 KB |
Output is correct |
31 |
Runtime error |
139 ms |
142788 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |