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;
#define mp make_pair
#define pb push_back
typedef long long int LLI;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
#define MOD 1000000007
LLI dp[3001][3001];
int main() {
int N,K;
cin >> N >> K;
K--;
int i,j;
dp[1][0] = 1;
for (i = 2; i <= N; i++) {
dp[i][0] = 1;
for (j = 1; j <= K; j++) dp[i][j] = (dp[i-1][j-1]*(i-j)+dp[i-1][j]*(j+1)) % MOD;
}
cout << dp[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... |