Advertisement
Guest User

Untitled

a guest
Feb 18th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. vector<long> R(100001, -1);
  7.  
  8. long fibo(long n)
  9. {
  10. if(R[n] != -1) return R[n];
  11. else if(n<2) return R[n] = n;
  12. return R[n] = (fibo(n-1)%100000007+fibo(n-2)%100000007)%100000007;
  13. }
  14.  
  15. int main()
  16. {
  17. long n;
  18. while(cin >> n) cout << fibo(n) << endl;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement