This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |