Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main() {
- ifstream fin("input.txt");
- ofstream fout("output.txt");
- int n, k;
- fin >> n >> k;
- vector<vector<vector<long long>>> dp(2 * n + 1, vector<vector<long long>>(2 * n + 1, vector<long long>(2*n + 1)));
- dp[0][0][0] = 1;
- for (int i = 0; i < 2 * n; i++)
- for (int j = 0; j <= i; j++)
- for (int g = 0; g <= i; g++) {
- dp[i + 1][j + 1][max(g, j + 1)] += dp[i][j][g];
- dp[i + 1][j + 1][max(g, j + 1)] %= 1000 * 1000 * 1000 + 7;
- if (j > 0) {
- dp[i + 1][j - 1][g] += dp[i][j][g];
- dp[i + 1][j - 1][max(g, j + 1)] %= 1000 * 1000 * 1000 + 7;
- }
- }
- fout << dp[2 * n][0][k] << endl;
- fin.close();
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment