Advertisement
LEGEND2004

D - Two digits

Aug 31st, 2023
737
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.26 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. int n;
  7. int f[50];
  8.  
  9. signed main()
  10. {
  11.     cin >> n;
  12.     f[1] = 2;
  13.     f[2] = 4;
  14.     for(int i = 3; i <= n; i++){
  15.         f[i] = f[i - 1] + f[i - 2];
  16.     }
  17.     cout << f[n] << endl;
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement