#include <bits/stdc++.h>
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
 
#define threesum cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
#define all(a) a.begin(), a.end()
#define F first
#define S second
#define int long long
#define pii pair<int, int>
#define ppp pair<int, pii>
#define dout cout << fixed << setprecision(15)
#define mid ((l + r) >> 1)
#define lc (id << 1)
#define rc (lc + 1)
mt19937 rng(chrono::steady_clock().now().time_since_epoch().count());
const int maxn = 1e6 + 10, maxm = 3e3 + 10, oo = 1e18 + 10, lg = 23, sq = 30, mod = 1e9 + 7;
int n, k;
int dp[maxm][maxm];
void solve(){
    cin >> n >> k;
    dp[1][1] = 1;
    for (int i = 2; i <= n;i++)
        for (int j = 1; j <= i;j++)
            dp[i][j] = (dp[i - 1][j] * j + dp[i - 1][j - 1] * (i + 1 - j)) % mod;
    cout << dp[n][k];
}
signed main()
{
    threesum;
    int t = 1;
    //cin >> t;
    while(t--)
        solve();
}
| # | 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... |