#include <iostream> using namespace std; #define MAX_l 28657 #define MAX_f 821223649 #define MAX_fl 23 int main() { float wynik; int t; int temp; int temp_w; cin>>t; //--- char tabtk[t]; int wyniki[MAX_fl]; int tab_w[MAX_fl]; int *tab1=new int[t]; //--- int fib[23]={1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657}; for(short int i=0;i<t;i++) { cin>>temp; *(tab1+i)=temp; tabtk[i]='x'; if(temp>MAX_f || temp<0) { tabtk[i]='n'; } if(temp==0) { tabtk[i]='t'; } for(short int j=0;j<MAX_fl;j++) { if (tabtk[i]=='n') { break; } if (tab1[i]>=fib[j] && (tab1[i])%(fib[j])==0 ) { wynik=((tab1[i])/(fib[j])); wyniki[j]=wynik; tab_w[j]=j; temp_w=j; } else { wyniki[j]=0; tab_w[j]=0; } } for(short int x=0;x<MAX_fl;x++) { for(short int j=0;j<MAX_fl;j++) { if (tabtk[i]=='n') { break; } if(wyniki[x]==fib[j]) { tabtk[i]='t'; } if(temp>MAX_f || temp<0) { tabtk[i]='n'; } } } } //wyswietl for(int i=0;i<t;i++) { if(tabtk[i]=='t') cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } delete []tab1; 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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | #include <iostream> using namespace std; #define MAX_l 28657 #define MAX_f 821223649 #define MAX_fl 23 int main() { float wynik; int t; int temp; int temp_w; cin>>t; //--- char tabtk[t]; int wyniki[MAX_fl]; int tab_w[MAX_fl]; int *tab1=new int[t]; //--- int fib[23]={1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657}; for(short int i=0;i<t;i++) { cin>>temp; *(tab1+i)=temp; tabtk[i]='x'; if(temp>MAX_f || temp<0) { tabtk[i]='n'; } if(temp==0) { tabtk[i]='t'; } for(short int j=0;j<MAX_fl;j++) { if (tabtk[i]=='n') { break; } if (tab1[i]>=fib[j] && (tab1[i])%(fib[j])==0 ) { wynik=((tab1[i])/(fib[j])); wyniki[j]=wynik; tab_w[j]=j; temp_w=j; } else { wyniki[j]=0; tab_w[j]=0; } } for(short int x=0;x<MAX_fl;x++) { for(short int j=0;j<MAX_fl;j++) { if (tabtk[i]=='n') { break; } if(wyniki[x]==fib[j]) { tabtk[i]='t'; } if(temp>MAX_f || temp<0) { tabtk[i]='n'; } } } } //wyswietl for(int i=0;i<t;i++) { if(tabtk[i]=='t') cout<<"TAK"<<endl; else cout<<"NIE"<<endl; } delete []tab1; return 0; } |