• + 0 comments

    C++ solution. This instructs the compiler to precompute the first 50 Fibonacci numbers, enough to satisfy the constraints.

    #include <bits/stdc++.h>
    
    using namespace std;
    
    constexpr array<long long, 50> compute() {
        array<long long, 50> fiboNums = {1, 1};
        long long fib1 = 1, fib2 = 1;
        for (int i = 2; i < 50; i++) {
            long long newFib = fib1 + fib2;
            fib1 = fib2, fib2 = newFib;
            fiboNums[i] = fib2;
        }
        return fiboNums;
    }
    
    array<long long, 50> fiboNums = compute();
    
    void solve() {
        long long n;
        cin >> n;
        
        if (*lower_bound(fiboNums.begin(), fiboNums.end(), n) != n)
            cout << "IsNotFibo" << endl;
        else
            cout << "IsFibo" << endl;
    }
    
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
            
        int t;
        cin >> t;
        
        while (t--)
            solve();
        
        return 0;
    }