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;
int main(){
long long n, k; cin >> n >> k;
k = n - k;
long long mod = 1e9 + 7;
vector<vector<long long>> dp(n+1, vector<long long>(k+1, 0));
for(long long i = 0; i < n+1; i ++){
dp[i][0] = 1;
if(i > 0) for(long long j = 1; j < k+1; j ++) dp[i][j] = ((dp[i-1][j-1] * (i - j)) % mod + (dp[i-1][j] * (j + 1)) % mod) % mod;
}
cout << dp[n][k];
}
# | 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... |