#include<iostream> #include<map> using namespace std; #define g {cout<<"TAK\n";goto d; int n,a=1,i;map<int,int>m;int main(){m[a]=1;while(a<1e9)m[i=a+n]=1,n=a,a=i;cin>>n;d:while(n--){cin>>a;if(!a)g}for(auto c:m)if(a%(i=c.first)<c.second&&m[a/i])g}cout<<"NIE\n";}return 0;}
1 2 3 4 5 | #include<iostream> #include<map> using namespace std; #define g {cout<<"TAK\n";goto d; int n,a=1,i;map<int,int>m;int main(){m[a]=1;while(a<1e9)m[i=a+n]=1,n=a,a=i;cin>>n;d:while(n--){cin>>a;if(!a)g}for(auto c:m)if(a%(i=c.first)<c.second&&m[a/i])g}cout<<"NIE\n";}return 0;} |