SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <iomanip>
  5. #include <random>
  6. #include <set>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.     int n;
  12.     cin >> n;
  13.     vector<int> dp(n + 1);
  14.     dp[0] = 1;
  15.     for (int i = 1; i <= n; ++i) {
  16.         dp[i] += dp[i - 1];
  17.         if (i - 2 >= 0) {
  18.             dp[i] += dp[i - 2];
  19.         }
  20.         if (i - 3 >= 0) {
  21.             dp[i] += dp[i - 3];
  22.         }
  23.     }
  24.     cout << dp[n];
  25.     return 0;
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top