Submission #68825

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
688252018-08-18 16:53:37IvanCAsceticism (JOI18_asceticism)C++17
49 / 100
139 ms142788 KiB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 3010;
const int MOD = 1e9 + 7;
ll dp[MAXN][MAXN];
int N,K;
ll solve(int dia,int grupos){
if(dp[dia][grupos] != -1) return dp[dia][grupos];
if(grupos == 0) return dp[dia][grupos] = 0;
if(dia == 1) return dp[dia][grupos] = (grupos == 1);
return dp[dia][grupos] = ((grupos)*solve(dia - 1,grupos) + (dia - grupos + 1)*solve(dia - 1,grupos - 1)) % MOD;
}
int main(){
memset(dp,-1,sizeof(dp));
cin >> N >> K;
cout << solve(N,K) << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...