Advertisement
Josif_tepe

Untitled

Apr 6th, 2022
1,023
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cmath>
  4. #include <math.h>
  5. #include <vector>
  6. #include <queue>
  7. using namespace std;
  8. long long dp[1005];
  9. long long fib(int number) {
  10.     if(number <= 2) {
  11.         return 1;
  12.     }
  13.     if(dp[number] != -1) {
  14.         return dp[number];
  15.     }
  16.     return dp[number] = fib(number - 1) + fib(number - 2);
  17. }
  18. int main()
  19. {
  20.     memset(dp, -1, sizeof dp);
  21.    
  22.     cout << fib(50) << endl;
  23.     return 0;
  24. }
  25.  
Advertisement
RAW Paste Data Copied
Advertisement