Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4.  
  5. int fib(int input, vector<int> &list){
  6. if(input>=60){
  7. input = input%60;
  8. }
  9. if(input >= list.size()){
  10. for (int i = list.size();i <= input; i++) {
  11. list.push_back((list[i-1]+list[i-2])%60);
  12. }
  13. return list[input];
  14. }else {
  15. return list[input];
  16. }
  17. }
  18.  
  19. int main()
  20. {
  21. int input;
  22. vector <int> list;
  23. list.push_back(0);
  24. list.push_back(1);
  25.  
  26. while(cin >> input){
  27. cout << fib(fib(input,list),list)%10 << " ";
  28. }
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement