Submission #147503

#TimeUsernameProblemLanguageResultExecution timeMemory
147503osaaateiasavtnlAsceticism (JOI18_asceticism)C++14
49 / 100
59 ms24952 KiB
#include<bits/stdc++.h> using namespace std; #define int long long #define ii pair <int, int> #define app push_back #define all(a) a.begin(), a.end() #define bp __builtin_popcount #define ll long long #define mp make_pair #define f first #define s second const int N = 3001, MOD = 1000 * 1000 * 1000 + 7; int n, k, dp[N][N]; void add(int &a, int b) { a += b; a %= MOD; } signed main() { #ifdef HOME freopen("input.txt", "r", stdin); #else ios_base::sync_with_stdio(0); cin.tie(0); #endif cin >> n >> k; --k; dp[1][0] = 1; for (int i = 1; i < n; ++i) { for (int j = 0; j <= k; ++j) { add(dp[i + 1][j], dp[i][j] * (j + 1)); add(dp[i + 1][j + 1], dp[i][j] * (i - j)); } } 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...