#include <iostream>
#include <algorithm>
using namespace std;
int t, f1, f2, g1, g2, x;
bool czy;
int main()
{
ios_base::sync_with_stdio(0);
cin >> t;
while (t>0)
{
cin >> x;
f1=0; f2=1;
while (f2<x)
{
f2=f1+f2;
f1=f2-f1;
};
czy=0;
g1=0; g2=1;
while ((czy==0) && (g1<=f2))
{
if (x==g1*f2)
czy=1;
if (x>g1*f2)
{
g2=g1+g2;
g1=g2-g1;
}
else if (x<g1*f2)
{
f1=f2-f1;
f2=f2-f1;
}
};
if (czy==1)
cout << "TAK" << '\n';
else
cout << "NIE" << '\n';
t--;
};
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 | #include <iostream> #include <algorithm> using namespace std; int t, f1, f2, g1, g2, x; bool czy; int main() { ios_base::sync_with_stdio(0); cin >> t; while (t>0) { cin >> x; f1=0; f2=1; while (f2<x) { f2=f1+f2; f1=f2-f1; }; czy=0; g1=0; g2=1; while ((czy==0) && (g1<=f2)) { if (x==g1*f2) czy=1; if (x>g1*f2) { g2=g1+g2; g1=g2-g1; } else if (x<g1*f2) { f1=f2-f1; f2=f2-f1; } }; if (czy==1) cout << "TAK" << '\n'; else cout << "NIE" << '\n'; t--; }; return 0; } |
English