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;
long long dp[3009][3009], mod = 1000000007;
long long solve(long long N, long long K) {
for (int i = 0; i <= N; i++) { for (int j = 0; j <= N; j++) dp[i][j] = 0; }
dp[0][0] = 1;
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dp[i + 1][j] += 1LL * (1LL + j) * dp[i][j]; dp[i + 1][j] %= mod;
dp[i + 1][j + 1] += 1LL * (i - j) * dp[i][j]; dp[i + 1][j + 1] %= mod;
}
}
return dp[N][K - 1];
}
int main() {
long long A, B; cin >> A >> B;
cout << solve(A, B) << 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... |