STANAANDREY

fibo dp

Dec 21st, 2020 (edited)
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.21 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int n, f[1003] = {0, 1};
  4.  
  5. int main() {
  6.     cin >> n;
  7.     for (int i = 2; i <= n; i++)
  8.         f[i] = f[i - 1] + f[i - 2];
  9.     cout << f[n] << endl;
  10.     return 0;
  11. }
  12.  
Add Comment
Please, Sign In to add comment