Submission #128157

#TimeUsernameProblemLanguageResultExecution timeMemory
128157RockyBAsceticism (JOI18_asceticism)C++17
49 / 100
179 ms35960 KiB
#include <bits/stdc++.h>

#define f first
#define s second

#define pb push_back
#define pp pop_back

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

#define rep(a, b, c) for (int a = (b); (a) <= (c); ++a)
#define per(a, b, c) for (int a = (b); (a) >= (c); --a) 

#define nl '\n'
#define ioi exit(0);

using namespace std;

typedef long long ll;

const int MAX_N = (int)3e3 + 7;
const int mod = (int)1e9 + 7;


int n, k;
int dp[MAX_N][MAX_N];
int calc(int v = 2, int cnt = 1) {
  if (v > n) return cnt == k;
  if (~dp[v][cnt]) return dp[v][cnt];
  return dp[v][cnt] = ((calc(v + 1, cnt) * 1ll * cnt % mod) + (calc(v + 1, cnt + 1) * 1ll * (v - cnt) % mod)) % mod;
}
int main() {
  #ifdef IOI
    freopen ("in.txt", "r", stdin);
  #endif
  cin >> n >> k;
  memset(dp, -1, sizeof(dp));
  cout << calc();
  ioi
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...