Submission #320391

#TimeUsernameProblemLanguageResultExecution timeMemory
320391NachoLibreAsceticism (JOI18_asceticism)C++14
49 / 100
50 ms25080 KiB
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const int N = 3003, K = N; int n, k, dp[N][K]; int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> k; dp[0][0] = 1; for(int i = 1; i <= n; ++i) { dp[i][0] = dp[i - 1][0]; for(int j = 1; j <= min(k, i - 1); ++j) { dp[i][j] = (1ll * dp[i - 1][j - 1] * (i - j) + 1ll * dp[i - 1][j] * (j + 1)) % mod; } } cout << dp[n][k - 1] << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...