Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4. typedef long long ll;
  5. map<int,int> mp;
  6.  
  7. ll Fib(ll n)
  8. {
  9. if(n<=1)
  10. return n;
  11. if(mp[n]) return mp[n];
  12. ll F=Fib(n-1)+Fib(n-2);
  13. mp[n]=F;
  14. return F;
  15. }
  16.  
  17. int main()
  18. {
  19. long long f;
  20. Fib(f/2);
  21. cin>>f;
  22. map<int,int>::iterator it;
  23. for(it=mp.begin();it!=mp.end();it++)
  24. {
  25. if((*it).second==f)
  26. {
  27. cout<<(*it).first;
  28. return 0;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement