#include <iostream>
using namespace std;
bool jest(int tab[], int value, int len){
for(int i=0; i<len; i++){
if(tab[i] == value)
return true;
}
return false;
}
int main(){
int a, b, tmp;
a = b = 1;
int liczby[45];
for(int i=1; i<=45; i++){
liczby[i-1] = a;
tmp = a + b;
a = b;
b = tmp;
}
//cout << liczby[44];
int n, m;
cin >> n;
for(int i=0; i<n; i++){
cin >> m;
if(m == 0){
cout << "TAK\n";
}
else{
bool bylo = false;
for(int j=0; j<45; j++){
if(m % liczby[j] == 0 && jest(liczby, m/liczby[j], 45)){
bylo = true;
cout << "TAK\n";
break;
}
}
if(bylo == false)
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 | #include <iostream> using namespace std; bool jest(int tab[], int value, int len){ for(int i=0; i<len; i++){ if(tab[i] == value) return true; } return false; } int main(){ int a, b, tmp; a = b = 1; int liczby[45]; for(int i=1; i<=45; i++){ liczby[i-1] = a; tmp = a + b; a = b; b = tmp; } //cout << liczby[44]; int n, m; cin >> n; for(int i=0; i<n; i++){ cin >> m; if(m == 0){ cout << "TAK\n"; } else{ bool bylo = false; for(int j=0; j<45; j++){ if(m % liczby[j] == 0 && jest(liczby, m/liczby[j], 45)){ bylo = true; cout << "TAK\n"; break; } } if(bylo == false) cout << "NIE\n"; } } return 0; } |
English