Advertisement
Josif_tepe

Untitled

Feb 17th, 2024
625
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. typedef long long ll;
  6. const int maxn = 105;
  7. const double EPS = 1e-7;
  8. int n;
  9. ll dp[100];
  10. ll rec(int at) {
  11.     if(at >= n) {
  12.         return 1;
  13.     }
  14.     if(dp[at] != -1) {
  15.         return dp[at];
  16.     }
  17.     ll res = 0;
  18.     res += rec(at + 1);
  19.    
  20.     for(int j = at + 3; j <= n; j++) {
  21.         res += rec(j + 1);
  22.     }
  23.     return dp[at] = res;
  24. }
  25. int main() {
  26.     ios_base::sync_with_stdio(false);
  27.     cin >> n;
  28.     memset(dp, -1, sizeof dp);
  29.     cout << rec(0) << endl;
  30.     return 0;
  31. }
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement