#include <iostream> #include <vector> std::vector<int> fibov; int fibogen(int k) { if(k==0 || k==1) return k; return((fibov.at(k-1)+fibov.at(k-2))); } int main() { std::vector<int> argv; int argc; std::cin>>argc; for(unsigned i=0;i<argc;i++) { int v; std::cin>>v; argv.push_back(v); } int maxvalue=0; for(unsigned i=0;i<argv.size();i++) { maxvalue = std::max(maxvalue, argv.at(i)); } //GENERATOR OF FIBONNACI'S int fibok=0; while(true) { int r=fibogen(fibok); fibov.push_back(r); fibok+=1; if(r>maxvalue) break; } for(unsigned i=0;i<argc;i++) { int fibval=1; while(true) { if(argv.at(i)%fibov.at(fibval) == 0) { int reszta = argv.at(i)/fibov.at(fibval); bool found=false; for(unsigned ia=0;ia<fibov.size();ia++) { if(reszta==fibov.at(ia)) { found=true; break; } } if(found) { std::cout<<"TAK"<<std::endl; break; } } fibval+=1; if(fibov.at(fibval)>argv.at(i)) { std::cout<<"NIE"<<std::endl; break; } } } }
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 | #include <iostream> #include <vector> std::vector<int> fibov; int fibogen(int k) { if(k==0 || k==1) return k; return((fibov.at(k-1)+fibov.at(k-2))); } int main() { std::vector<int> argv; int argc; std::cin>>argc; for(unsigned i=0;i<argc;i++) { int v; std::cin>>v; argv.push_back(v); } int maxvalue=0; for(unsigned i=0;i<argv.size();i++) { maxvalue = std::max(maxvalue, argv.at(i)); } //GENERATOR OF FIBONNACI'S int fibok=0; while(true) { int r=fibogen(fibok); fibov.push_back(r); fibok+=1; if(r>maxvalue) break; } for(unsigned i=0;i<argc;i++) { int fibval=1; while(true) { if(argv.at(i)%fibov.at(fibval) == 0) { int reszta = argv.at(i)/fibov.at(fibval); bool found=false; for(unsigned ia=0;ia<fibov.size();ia++) { if(reszta==fibov.at(ia)) { found=true; break; } } if(found) { std::cout<<"TAK"<<std::endl; break; } } fibval+=1; if(fibov.at(fibval)>argv.at(i)) { std::cout<<"NIE"<<std::endl; break; } } } } |