Submission #752599

#TimeUsernameProblemLanguageResultExecution timeMemory
752599bgnbvnbvAsceticism (JOI18_asceticism)C++14
4 / 100
1 ms724 KiB
#include<bits/stdc++.h> #define TASKNAME "codeforce" #define pb push_back #define pli pair<int,int> #define fi first #define se second #define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); using namespace std; using ll=long long; const ll maxN=2e5; const ll inf=1e18; const ll mod=1e9+7; ll dp[3005][3005],n,k; void solve() { cin >> n >> k; dp[1][0]=1; for(int i=1;i<n;i++) { for(int j=0;j<=i-1;j++) { dp[i][j]%=mod; dp[i+1][j+1]+=dp[i][j]; dp[i+1][j]+=dp[i][j]; dp[i+1][j]+=j*dp[i][j]%mod; dp[i+1][j+1]+=(i-1-j)*dp[i][j]%mod; } } cout << dp[n][k-1]; } int main() { fastio //freopen(TASKNAME".INP","r",stdin); //freopen(TASKNAME".OUT","w",stdout); solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...