Advertisement
mickypinata

AJJak-T003: Tiling-03

Dec 3rd, 2021
599
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long lli;
  5.  
  6. const int N = 1000 + 5;
  7. const int MD = 1e9 + 7;
  8.  
  9. int dp1[N], dp2[N];
  10.  
  11. int main(){
  12.  
  13.     int n;
  14.     scanf("%d", &n);
  15.     dp1[0] = 1;
  16.     dp1[1] = 1;
  17.     for(int i = 1; i <= n; ++i){
  18.         dp1[i] = ((lli)dp1[i - 1] + dp1[i - 2] + 2 * (lli)dp2[i - 1]) % MD;
  19.         dp2[i] = ((lli)dp1[i - 2] + dp2[i - 1]) % MD;
  20.     }
  21.     cout << dp1[n];
  22.  
  23.     return 0;
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement