#include <iostream>
#include <vector>
#include <algorithm>
void init(std::vector<long> &fn, long max) {
long a=2,b=1;
while( a <= max )
{
fn.push_back(a);
int t= a+b;
b=a;a=t;
}
}
int main()
{
std::vector<long> fn;
init(fn,1000000000);
unsigned n;
std::cin >> n;
while(n--)
{
long num;
std::cin >> num;
if(num == 0 || num == 1)
{
std::cout << "TAK" << std::endl;
continue;
}
for( long a : fn )
{
if( num % a ) continue;
long o = num / a;
if( o == 1 || std::binary_search(fn.begin(),fn.end(),o) )
{
std::cout << "TAK" << std::endl;
num=0;
break;
}
}
if( num ) std::cout << "NIE " << std::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 | #include <iostream> #include <vector> #include <algorithm> void init(std::vector<long> &fn, long max) { long a=2,b=1; while( a <= max ) { fn.push_back(a); int t= a+b; b=a;a=t; } } int main() { std::vector<long> fn; init(fn,1000000000); unsigned n; std::cin >> n; while(n--) { long num; std::cin >> num; if(num == 0 || num == 1) { std::cout << "TAK" << std::endl; continue; } for( long a : fn ) { if( num % a ) continue; long o = num / a; if( o == 1 || std::binary_search(fn.begin(),fn.end(),o) ) { std::cout << "TAK" << std::endl; num=0; break; } } if( num ) std::cout << "NIE " << std::endl; } return 0; } |
English