Submission #974422

#TimeUsernameProblemLanguageResultExecution timeMemory
974422SharkyAsceticism (JOI18_asceticism)C++17
49 / 100
32 ms25152 KiB
// dp[i][j] -> dp[i+1][j] * j // dp[i][j] -> dp[i+1][j+1] * (i-j+1); #include <bits/stdc++.h> using namespace std; #define int long long const int mod = 1e9 + 7; int dp[3002][3002]; int n, k; int32_t main() { int n, k; cin >> n >> k; dp[0][0] = 1; for (int i = 0; i <= n; i++) for (int j = 0; j <= k; j++) { dp[i+1][j] += dp[i][j] * j % mod; dp[i+1][j] %= mod; dp[i+1][j+1] += dp[i][j] * (i-j+1) % mod; dp[i+1][j+1] %= mod; } cout << dp[n][k] << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...