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