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>
#define st first
#define nd second
#define mp make_pair
#ifndef LOCAL
#define cerr if(0)cerr
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pii = pair<int, int>;
const ll mod = 1e9+7;
const int N = 3e3+1;
int n, K;
ll dp[N][N];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin>>n>>K;
dp[0][0] = 1;
for(int i=1; i<=n; ++i) {
dp[i][0] = 1;
for(int j=1; j<=i; ++j) {
dp[i][j] = (dp[i-1][j-1] * (i-j) + dp[i-1][j] * (j+1))%mod;
}
}
cout<<dp[n][K-1]<<'\n';
}
# | 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... |