Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <map>
- using namespace std;
- typedef long long ll;
- map<int,int> mp;
- ll Fib(ll n)
- {
- if(n<=1)
- return n;
- if(mp[n]) return mp[n];
- ll F=Fib(n-1)+Fib(n-2);
- mp[n]=F;
- return F;
- }
- int main()
- {
- long long f;
- Fib(f/2);
- cin>>f;
- map<int,int>::iterator it;
- for(it=mp.begin();it!=mp.end();it++)
- {
- if((*it).second==f)
- {
- cout<<(*it).first;
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement