#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <iterator>
#include <memory>
#include <numeric>
#include <functional>
#include <sstream>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <stack>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <tuple>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <climits>
#include <ctime>
using namespace std;
#define rep(i, x, y) for(int i = x; i <= y; ++i)
#define mp make_pair
#define add push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mem(a,b) memset(a, b, sizeof(a))
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:20000007")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef pair <int, int> pii;
typedef vector <int> lnum;
const int N = (int)1e6 + 100;
const int maxn = (int)1e3 + 100;
const int base = (int)1e9;
const int mod = (int)1e9 + 7;
const int inf = INT_MAX;
const long long ll_inf = LLONG_MAX;
const long double pi = acos((long double)-1.0);
const long double eps = 1e-8;
#define int int64_t
int dp[3003][3003] = { 0 };
void solve() {
int n, k; cin >> n >> k;
dp[1][1] = 1;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= k; ++j) {
if (i == 1 && j == 1) continue;
dp[i][j] = (j * dp[i - 1][j]) % mod + ((i - j + 1) * dp[i - 1][j - 1]) % mod;
dp[i][j] %= mod;
}
}
cout << dp[n][k] << '\n';
}
int32_t main() {
//ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
//#define Freopen
#ifdef Freopen
#ifndef _MSC_VER
#define TASK ""
freopen(TASK".in", "r", stdin);
freopen(TASK".out", "w", stdout);
#endif
#endif
int T = 1;
//scanf("%d", &T);
for (; T; --T) solve();
#ifdef DEBUG
cerr << double(1.0 * clock() / CLOCKS_PER_SEC) << '\n';
#endif
return 0;
}
Compilation message
asceticism.cpp:38:0: warning: ignoring #pragma warning [-Wunknown-pragmas]
#pragma warning(disable:4996)
asceticism.cpp:39:0: warning: ignoring #pragma comment [-Wunknown-pragmas]
#pragma comment(linker, "/STACK:20000007")
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
912 KB |
Output is correct |
12 |
Correct |
2 ms |
1680 KB |
Output is correct |
13 |
Correct |
2 ms |
1680 KB |
Output is correct |
14 |
Correct |
3 ms |
1936 KB |
Output is correct |
15 |
Correct |
3 ms |
2448 KB |
Output is correct |
16 |
Correct |
4 ms |
2448 KB |
Output is correct |
17 |
Correct |
2 ms |
2448 KB |
Output is correct |
18 |
Correct |
3 ms |
2448 KB |
Output is correct |
19 |
Correct |
2 ms |
2448 KB |
Output is correct |
20 |
Correct |
2 ms |
2448 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
912 KB |
Output is correct |
12 |
Correct |
2 ms |
1680 KB |
Output is correct |
13 |
Correct |
2 ms |
1680 KB |
Output is correct |
14 |
Correct |
3 ms |
1936 KB |
Output is correct |
15 |
Correct |
3 ms |
2448 KB |
Output is correct |
16 |
Correct |
4 ms |
2448 KB |
Output is correct |
17 |
Correct |
2 ms |
2448 KB |
Output is correct |
18 |
Correct |
3 ms |
2448 KB |
Output is correct |
19 |
Correct |
2 ms |
2448 KB |
Output is correct |
20 |
Correct |
2 ms |
2448 KB |
Output is correct |
21 |
Correct |
4 ms |
4656 KB |
Output is correct |
22 |
Correct |
5 ms |
4656 KB |
Output is correct |
23 |
Correct |
11 ms |
8092 KB |
Output is correct |
24 |
Correct |
10 ms |
8556 KB |
Output is correct |
25 |
Correct |
14 ms |
12012 KB |
Output is correct |
26 |
Correct |
15 ms |
12396 KB |
Output is correct |
27 |
Correct |
15 ms |
12396 KB |
Output is correct |
28 |
Correct |
7 ms |
12396 KB |
Output is correct |
29 |
Correct |
2 ms |
12396 KB |
Output is correct |
30 |
Correct |
14 ms |
12396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
556 KB |
Output is correct |
4 |
Correct |
2 ms |
556 KB |
Output is correct |
5 |
Correct |
2 ms |
556 KB |
Output is correct |
6 |
Correct |
2 ms |
556 KB |
Output is correct |
7 |
Correct |
2 ms |
556 KB |
Output is correct |
8 |
Correct |
2 ms |
556 KB |
Output is correct |
9 |
Correct |
2 ms |
556 KB |
Output is correct |
10 |
Correct |
2 ms |
556 KB |
Output is correct |
11 |
Correct |
2 ms |
912 KB |
Output is correct |
12 |
Correct |
2 ms |
1680 KB |
Output is correct |
13 |
Correct |
2 ms |
1680 KB |
Output is correct |
14 |
Correct |
3 ms |
1936 KB |
Output is correct |
15 |
Correct |
3 ms |
2448 KB |
Output is correct |
16 |
Correct |
4 ms |
2448 KB |
Output is correct |
17 |
Correct |
2 ms |
2448 KB |
Output is correct |
18 |
Correct |
3 ms |
2448 KB |
Output is correct |
19 |
Correct |
2 ms |
2448 KB |
Output is correct |
20 |
Correct |
2 ms |
2448 KB |
Output is correct |
21 |
Correct |
4 ms |
4656 KB |
Output is correct |
22 |
Correct |
5 ms |
4656 KB |
Output is correct |
23 |
Correct |
11 ms |
8092 KB |
Output is correct |
24 |
Correct |
10 ms |
8556 KB |
Output is correct |
25 |
Correct |
14 ms |
12012 KB |
Output is correct |
26 |
Correct |
15 ms |
12396 KB |
Output is correct |
27 |
Correct |
15 ms |
12396 KB |
Output is correct |
28 |
Correct |
7 ms |
12396 KB |
Output is correct |
29 |
Correct |
2 ms |
12396 KB |
Output is correct |
30 |
Correct |
14 ms |
12396 KB |
Output is correct |
31 |
Runtime error |
56 ms |
25060 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
32 |
Halted |
0 ms |
0 KB |
- |