Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement