Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- int fib(int input, vector<int> &list){
- if(input>=60){
- input = input%60;
- }
- if(input >= list.size()){
- for (int i = list.size();i <= input; i++) {
- list.push_back((list[i-1]+list[i-2])%60);
- }
- return list[input];
- }else {
- return list[input];
- }
- }
- int main()
- {
- int input;
- vector <int> list;
- list.push_back(0);
- list.push_back(1);
- while(cin >> input){
- cout << fib(fib(input,list),list)%10 << " ";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement