#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pull;
typedef pair<int, int> pii;
typedef pair<ld, ld> pld;
const ll mod = 1e9+7;
ll n, k;
ll dp[3009][3009];
int main() {
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
cin >> n >> k;
for(ll i = 1; i <= n; ++i){
dp[i][1] = 1;
for(ll j = 1; j <= k; ++j){
dp[i+1][j] += dp[i][j]*j;
dp[i+1][j] %= mod;
dp[i+1][j+1] += dp[i][j]*(i-j+1);
dp[i+1][j+1] %= mod;
}
}
cout << dp[n][k] << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2176 KB |
Output is correct |
16 |
Correct |
2 ms |
2176 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2176 KB |
Output is correct |
16 |
Correct |
2 ms |
2176 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4352 KB |
Output is correct |
23 |
Correct |
8 ms |
7936 KB |
Output is correct |
24 |
Correct |
8 ms |
8320 KB |
Output is correct |
25 |
Correct |
12 ms |
11784 KB |
Output is correct |
26 |
Correct |
14 ms |
12160 KB |
Output is correct |
27 |
Correct |
12 ms |
12160 KB |
Output is correct |
28 |
Correct |
5 ms |
5248 KB |
Output is correct |
29 |
Correct |
1 ms |
1280 KB |
Output is correct |
30 |
Correct |
12 ms |
11904 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
0 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
0 ms |
384 KB |
Output is correct |
6 |
Correct |
0 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 |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
1 ms |
768 KB |
Output is correct |
12 |
Correct |
1 ms |
1536 KB |
Output is correct |
13 |
Correct |
1 ms |
1536 KB |
Output is correct |
14 |
Correct |
2 ms |
1792 KB |
Output is correct |
15 |
Correct |
2 ms |
2176 KB |
Output is correct |
16 |
Correct |
2 ms |
2176 KB |
Output is correct |
17 |
Correct |
1 ms |
1152 KB |
Output is correct |
18 |
Correct |
2 ms |
1664 KB |
Output is correct |
19 |
Correct |
1 ms |
1024 KB |
Output is correct |
20 |
Correct |
0 ms |
384 KB |
Output is correct |
21 |
Correct |
3 ms |
4352 KB |
Output is correct |
22 |
Correct |
3 ms |
4352 KB |
Output is correct |
23 |
Correct |
8 ms |
7936 KB |
Output is correct |
24 |
Correct |
8 ms |
8320 KB |
Output is correct |
25 |
Correct |
12 ms |
11784 KB |
Output is correct |
26 |
Correct |
14 ms |
12160 KB |
Output is correct |
27 |
Correct |
12 ms |
12160 KB |
Output is correct |
28 |
Correct |
5 ms |
5248 KB |
Output is correct |
29 |
Correct |
1 ms |
1280 KB |
Output is correct |
30 |
Correct |
12 ms |
11904 KB |
Output is correct |
31 |
Runtime error |
52 ms |
25176 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |