fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. int f[1000005];
  9. f[0] = 0;
  10. f[1] = 1;
  11. for (int i = 2; i <= n; ++i) {
  12. f[i] = f[i - 1] + f[i - 2];
  13. }
  14.  
  15. cout << f[n];
  16.  
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0.01s 5284KB
stdin
8
stdout
21