Submission #100868

#TimeUsernameProblemLanguageResultExecution timeMemory
100868TAISA_Asceticism (JOI18_asceticism)C++14
49 / 100
15 ms8448 KiB
#include<bits/stdc++.h> #define all(vec) vec.begin(),vec.end() using namespace std; using ll=long long; const ll MOD=1000000007LL; template<typename T> void chmax(T &a,T b){a=max(a,b);} template<typename T> void chmin(T &a,T b){a=min(a,b);} int main(){ ll n,k;cin>>n>>k;if(n>3000)return 0; vector<vector<ll>> dp(n+10,vector<ll>(n+10)); dp[0][0]=1; for(ll i=1;i<=n;i++){ for(ll j=0;j<i;j++){//i+1通り挿入できる dp[i][j]+=dp[i-1][j]*(j+1LL)%MOD; if(j>0){ dp[i][j]+=dp[i-1][j-1]*(i-j)%MOD; } dp[i][j]%=MOD; } } cout<<dp[n][k-1]<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...