Submission #474620

#TimeUsernameProblemLanguageResultExecution timeMemory
474620prvocisloAsceticism (JOI18_asceticism)C++17
49 / 100
46 ms24964 KiB
#include <iostream> #include <vector> #include <algorithm> #include <string> typedef long long ll; using namespace std; const int maxn = 3005, mod = 1e9 + 7; int dp[maxn][maxn]; int mul(const int& a, const int& b) { return (a * 1ll * b) % (ll)mod; } void upd(int& a, const int& b) { a = (a + b) % mod; } int main() { ios::sync_with_stdio(false); cin.tie(0); int N, K; cin >> N >> K; dp[1][1] = 1; for (int n = 2; n <= N; n++) for (int k = 1; k <= min(K, n); k++) { upd(dp[n][k], mul(dp[n - 1][k], k)); // umiestnime ho na koniec jedneho z k usekov upd(dp[n][k], mul(dp[n - 1][k - 1], n - k + 1)); // umiestnime ho inde a vytvorime novy usek } cout << dp[N][K] << "\n"; 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...