Submission #100558

#TimeUsernameProblemLanguageResultExecution timeMemory
100558JPN20Asceticism (JOI18_asceticism)C++17
49 / 100
302 ms142256 KiB
#include <bits/stdc++.h> using namespace std; long long dp[3009][3009], mod = 1000000007; long long solve(long long N, long long K) { for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) dp[i][j] = 0; } dp[0][0] = 1; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { dp[i + 1][j] += 1LL * (1LL + j) * dp[i][j]; dp[i + 1][j] %= mod; dp[i + 1][j + 1] += 1LL * (i - j) * dp[i][j]; dp[i + 1][j + 1] %= mod; } } return dp[N][K - 1]; } int main() { long long A, B; cin >> A >> B; cout << solve(A, B) << 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...