#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
bool odp=false;
int n,t;
int tab[50];
tab[0]=0;
tab[1]=1;
tab[2]=1;
for(int i=3;i<41;i++)
{
tab[i]=tab[i-1]+tab[i-2];
}
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&t);
if(t==0)
{
printf("TAK\n");
continue;
}
for(int j=1;j<41;j++)
{
for(int k=j;k<41;k++)
{
if(tab[j]*tab[k]==t)
odp=true;
if(tab[j]*tab[k]>t)
break;
}
}
if(odp==true)
printf("TAK\n");
else
printf("NIE\n");
odp=false;
}
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 | #include<iostream> #include<cstdio> using namespace std; int main() { bool odp=false; int n,t; int tab[50]; tab[0]=0; tab[1]=1; tab[2]=1; for(int i=3;i<41;i++) { tab[i]=tab[i-1]+tab[i-2]; } scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d",&t); if(t==0) { printf("TAK\n"); continue; } for(int j=1;j<41;j++) { for(int k=j;k<41;k++) { if(tab[j]*tab[k]==t) odp=true; if(tab[j]*tab[k]>t) break; } } if(odp==true) printf("TAK\n"); else printf("NIE\n"); odp=false; } return 0; } |
polski