#include <iostream>
#include<cstdio>
#include <math.h>
using namespace std;
int main() {
long t[46];
t[0]=0;
t[1]=1;
t[2]=1;
for (int i=2; i<46; i++) {
t[i]=t[i-1]+t[i-2];
//cout<<t[i]<<endl;
}
int z;
scanf("%d",&z);
while(z--) {
long a;
scanf("%ld",&a);
bool pom=false;
for (int i=0; i<46; i++) {
if ((a==t[i]) || (sqrt(a)==t[i])){
pom=true;
break;
}
}
if (pom==true) {
printf("TAK\n");
} else {
for (int i=3; i<46; i++) {
if (a%t[i]==0) {
int pom2=false;
for (int j=i; j<46; j++) {
if (a/t[i]==t[j]) {
pom=true;
pom2=true;
break;
}
}
if (pom2==true) {
break;
}
}
}
if (pom==true) {
printf("TAK\n");
}
}
if (pom==false) {
printf("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 53 54 55 | #include <iostream> #include<cstdio> #include <math.h> using namespace std; int main() { long t[46]; t[0]=0; t[1]=1; t[2]=1; for (int i=2; i<46; i++) { t[i]=t[i-1]+t[i-2]; //cout<<t[i]<<endl; } int z; scanf("%d",&z); while(z--) { long a; scanf("%ld",&a); bool pom=false; for (int i=0; i<46; i++) { if ((a==t[i]) || (sqrt(a)==t[i])){ pom=true; break; } } if (pom==true) { printf("TAK\n"); } else { for (int i=3; i<46; i++) { if (a%t[i]==0) { int pom2=false; for (int j=i; j<46; j++) { if (a/t[i]==t[j]) { pom=true; pom2=true; break; } } if (pom2==true) { break; } } } if (pom==true) { printf("TAK\n"); } } if (pom==false) { printf("NIE\n"); } } return 0; } |
English