Submission #330766

#TimeUsernameProblemLanguageResultExecution timeMemory
330766pit4hAsceticism (JOI18_asceticism)C++14
49 / 100
118 ms94848 KiB
#include<bits/stdc++.h> #define st first #define nd second #define mp make_pair #ifndef LOCAL #define cerr if(0)cerr #endif using namespace std; using ll = long long; using ld = long double; using vi = vector<int>; using pii = pair<int, int>; const ll mod = 1e9+7; const int N = 3e3+1; int n, K; ll dp[N][N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>K; dp[0][0] = 1; for(int i=1; i<=n; ++i) { dp[i][0] = 1; for(int j=1; j<=i; ++j) { dp[i][j] = (dp[i-1][j-1] * (i-j) + dp[i-1][j] * (j+1))%mod; } } cout<<dp[n][K-1]<<'\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...