#pragma GCC optimize("Ofast,unroll-loops,inline")
#include <bits/stdc++.h>
#pragma GCC target("avx2")
using namespace std;
using ll = long long;
const int M = 1e9 + 7;
int N, K;
ll dp[100000]{1}, dp2[100000]{1};
int main() {
cin >> N >> K;
for (int n = 1; n <= N;) {
for (int k = n; k > 0; --k) {
dp2[k] = (dp[k] * (k + 1) + dp[k - 1] * (n - k)) % M;
}
if (n++ == N) cout << dp2[K - 1];
for (int k = n; k > 0; --k) {
dp[k] = (dp2[k] * (k + 1) + dp2[k - 1] * (n - k)) % M;
}
if (n++ == N) cout << dp[K - 1];
}
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |