#include <iostream>
#include <set>
using namespace std;
int main()
{
ios_base::sync_with_stdio(false);
int a=0,b=1,c;
set<int> s;
s.insert(1);
while(b<1000000000)
{
c=a+b;
s.insert(c);
a=b;
b=c;
}
int z;
cin>>z;
for(;z>0;z--)
{
int n;
cin>>n;
if(n==0)
{
cout<<"TAK\n";
}
else
{
bool flag=false;
for(set<int>::iterator it=s.begin();it!=s.end();it++)
{
if(n%(*it)==0)
{
if(s.find(n/(*it))!=s.end())
{
flag=true;
break;
}
}
}
if(flag)
{
cout<<"TAK\n";
}
else
{
cout<<"NIE\n";
}
}
}
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 | #include <iostream> #include <set> using namespace std; int main() { ios_base::sync_with_stdio(false); int a=0,b=1,c; set<int> s; s.insert(1); while(b<1000000000) { c=a+b; s.insert(c); a=b; b=c; } int z; cin>>z; for(;z>0;z--) { int n; cin>>n; if(n==0) { cout<<"TAK\n"; } else { bool flag=false; for(set<int>::iterator it=s.begin();it!=s.end();it++) { if(n%(*it)==0) { if(s.find(n/(*it))!=s.end()) { flag=true; break; } } } if(flag) { cout<<"TAK\n"; } else { cout<<"NIE\n"; } } } return 0; } |
English