fork download
  1. //Bai 16
  2.  
  3. #include<bits/stdc++.h>
  4. using namespace std;
  5. #define el "\n"
  6. #define ll long long
  7. #define ull unsigned long long
  8. #define se second
  9. #define fi first
  10. #define be begin()
  11. #define en end()
  12. #define Faster cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
  13. int n;
  14. ll solve(int n)
  15. {
  16. if(n == 0) return 1;
  17. if(n == 1) return 2;
  18. return 3*solve(n-1) - 2*solve(n-2);
  19. }
  20. void Run()
  21. {
  22. cin >> n;
  23. cout << solve(n);
  24. }
  25. int main()
  26. {
  27. Faster;
  28. Run();
  29. return 0;
  30. }
  31.  
  32.  
Success #stdin #stdout 0s 5292KB
stdin
Standard input is empty
stdout
1