#include <stdlib.h>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <deque>
#define FOR(x,z) for(int x=0;x<(z);++x)
#define DS(i) fprintf(stderr, "DEBUG: %s\n",i);
#define DI(i) fprintf(stderr, "DEBUG: %d\n",i);
#define DF(i) fprintf(stderr, "DEBUG: %f\n",i);
using namespace std;
vector<bool> b;
int n;
void fillFib()
{
b[0]=b[1]=true;
int p1=0,p2=1,n=p1+p2;
while(n<1000000001)
{
b[n]=true;
p1=p2;
p2=n;
n=p1+p2;
}
}
void wczytaj()
{
cin >> n;
}
void wykonaj()
{
for(int i =1;i<=sqrt(n);i++)
{
if((n%i)==0)
{
if(b[i]&&b[n/i])
{
printf("%s\n", "TAK");
return;
}
}
}
printf("%s\n", "NIE");
}
int main()
{
b.assign(1000000001,false);
fillFib();
int T;
scanf("%d",&T);
for(int t=1;t<=T;t++)
{
wczytaj();
//DI(t)
//printf("Case #%d: ",t);
wykonaj();
}
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 56 57 58 59 60 61 | #include <stdlib.h> #include <cstdio> #include <algorithm> #include <iostream> #include <string> #include <vector> #include <cmath> #include <deque> #define FOR(x,z) for(int x=0;x<(z);++x) #define DS(i) fprintf(stderr, "DEBUG: %s\n",i); #define DI(i) fprintf(stderr, "DEBUG: %d\n",i); #define DF(i) fprintf(stderr, "DEBUG: %f\n",i); using namespace std; vector<bool> b; int n; void fillFib() { b[0]=b[1]=true; int p1=0,p2=1,n=p1+p2; while(n<1000000001) { b[n]=true; p1=p2; p2=n; n=p1+p2; } } void wczytaj() { cin >> n; } void wykonaj() { for(int i =1;i<=sqrt(n);i++) { if((n%i)==0) { if(b[i]&&b[n/i]) { printf("%s\n", "TAK"); return; } } } printf("%s\n", "NIE"); } int main() { b.assign(1000000001,false); fillFib(); int T; scanf("%d",&T); for(int t=1;t<=T;t++) { wczytaj(); //DI(t) //printf("Case #%d: ",t); wykonaj(); } return 0; } |
English