mickypinata

AJJak-T004: Tiling-3.5

Dec 3rd, 2021
519
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long lli;
  5.  
  6. const int N = 1000 + 5;
  7.  
  8. lli dp1[N], dp2[N], dp3[N];
  9.  
  10. int main(){
  11.  
  12.     int n;
  13.     scanf("%d", &n);
  14.     int lst = 5;
  15.     dp1[0] = 1; dp1[1] = 1;
  16.     dp2[0] = 1; dp2[1] = 2;
  17.     dp3[0] = 1; dp3[1] = 1;
  18.     for(int i = 2; i <= n; ++i){
  19.         dp1[i] = dp1[i - 1] + dp1[i - 2] + 2 * dp2[i - 2] + dp3[i - 2];
  20.         dp2[i] = dp1[i] + dp2[i - 1];
  21.         dp3[i] = dp1[i] + dp3[i - 2];
  22.  
  23.     }
  24.     cout << dp1[n];
  25.  
  26.     return 0;
  27. }
  28.  
RAW Paste Data