Untitled
raw download clone
TEXT
views 15
,
size 509 b
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("fiboverif1.in");
ofstream fout("fiboverif1.out");
bool fib(int n)
{
    if (n==1)
        return true;
    int a=1,b=1,c;
    while(b<n)
    {
        c=a+b;
        a=b;
        b=c;
    }
    if (b==n)
        return true;
    return false;
}

int main ()
{
    int n, x;
    fin>>n;
    for(int i=1;i<=n;i++)
    {
        fin>>x;
        if (fib(x))
            fout<<x<<" ";
    }
    return 0;
}
close fullscreen
Login or Register to edit or fork this paste. It's free.