let's start Code

Is Fibo

Is Fibo

Topic: Fibonacci

#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define maxn 100005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
map<ll, bool> ans;
void fib()
{
ll a = 0;
ll b = 1;
ans[a] = true;
ans[b] = true;
ll c = a + b;
while(c <= 1e10){
ans[c] = true;
a = b;
b = c;
c = a + b;
//cerr << c << endl;
}
}
int main()
{
FASTIO
///*
//double start_time = clock();
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
freopen("error.txt", "w", stderr);
#endif //*/
fib();
int T;
cin >> T;
while(T--){
ll x;
cin >> x;
if(ans[x]) cout << "IsFibo\n";
else cout << "IsNotFibo\n";
}
//double end_time = clock();
//printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
return 0;
}
view raw Isfib.cpp hosted with ❤ by GitHub
Share:

Related Posts:

No comments:

Post a Comment

About

let's start CODE

Popular Posts