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