#include <iostream>
using namespace std;
int istnieje (long int T[],int n, long int key)
{
for (int i=0;i<=n;i++)
{
if (T[i]==key)
return 1;
}
return 0;
}
long int FIB[50];
int main()
{
int t;
cin>>t;
FIB[0]=0;
FIB[1]=1;
int k=1;
while (FIB[k]<=1000000000)
{
k++;
FIB[k]=FIB[k-1]+FIB[k-2];
}
for (int i=0;i<t;i++)
{
long int n;
cin >> n;
if (n==0)
cout << "TAK";
else
{
int ww=0;
int j=1;
while (j<k)
{
if (n % FIB[j]==0)
{
long int m = n / FIB[j];
int wynik = istnieje(FIB,k,m);
if (wynik==1)
{
ww=1;
j=k;
}
}
j++;
}
if (ww==1)
cout <<"TAK" <<endl;
else
cout <<"NIE" <<endl;
}
}
return 0;
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | #include <iostream> using namespace std; int istnieje (long int T[],int n, long int key) { for (int i=0;i<=n;i++) { if (T[i]==key) return 1; } return 0; } long int FIB[50]; int main() { int t; cin>>t; FIB[0]=0; FIB[1]=1; int k=1; while (FIB[k]<=1000000000) { k++; FIB[k]=FIB[k-1]+FIB[k-2]; } for (int i=0;i<t;i++) { long int n; cin >> n; if (n==0) cout << "TAK"; else { int ww=0; int j=1; while (j<k) { if (n % FIB[j]==0) { long int m = n / FIB[j]; int wynik = istnieje(FIB,k,m); if (wynik==1) { ww=1; j=k; } } j++; } if (ww==1) cout <<"TAK" <<endl; else cout <<"NIE" <<endl; } } return 0; } |
English