Raslboyy

211

Sep 16th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <vector>
  4. #include <algorithm>
  5. #include <numeric>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10.     ifstream fin("input.txt");
  11.     ofstream fout("output.txt");
  12.  
  13.     int n;
  14.     fin >> n;
  15.     vector<vector<int>> dp(n + 1, vector<int>(n + 2));
  16.     dp[0][n + 1] = 1;
  17.     for (int i = 0; i < n; i++)
  18.         for (int j = 0; j <= n + 1; j++)
  19.             for (int k = 1; k < min(j, n - i + 1); k++)
  20.                 dp[i + k][k] += dp[i][j];
  21.            
  22.     fout << accumulate(dp[n].begin(), dp[n].end(), 0) << endl;
  23.  
  24.     fin.close();
  25.     fout.close();
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment