Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- vector<long> R(100001, -1);
- long fibo(long n)
- {
- if(R[n] != -1) return R[n];
- else if(n<2) return R[n] = n;
- return R[n] = (fibo(n-1)%100000007+fibo(n-2)%100000007)%100000007;
- }
- int main()
- {
- long n;
- while(cin >> n) cout << fibo(n) << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement