Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- https://trello.com/c/cFURddke/105-hackerrank-is-fibo
- https://www.hackerrank.com/challenges/is-fibo/problem
- #include <iostream> // std::cout
- #include <vector> // std::swap
- #include <algorithm> // std::binary_search, std::sort
- using namespace std;
- int main()
- {
- int N=50;
- vector <long> f (N+1);
- f[0]=0;
- f[1]=1;
- for(int i=2; i<=N; i++)
- f[i]=f[i-1]+f[i-2];
- int T;
- cin>>T;
- for(int i=0; i<T; i++)
- {
- int t;
- cin>>t;
- if ( binary_search (f.begin(), f.end(), t) )
- cout<<"IsFibo"<<endl;
- else
- cout<<"IsNotFibo"<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment