fork download
  1. #include<iostream>
  2. using namespace std;
  3. void sito(int *tab, int x)
  4. {
  5. for (int i=2; i*i<=x; i++)
  6. {
  7. if(!tab[i])
  8. for (int j = i*i ; j<=x; j+=i)
  9. tab[j] = 1;
  10. }
  11. }
  12. int main()
  13. {
  14. int n,t,tab[1000000];
  15. int x=0,y=0;
  16. sito(tab, 1000000);
  17. tab[1]=1;
  18. tab[0]=1;
  19.  
  20. cin>>t;
  21. while(t--)
  22. {
  23. cin>>n;
  24. if(n==0)
  25. cout<<"NIE"<<endl;
  26. else
  27. {
  28. while(n>0)
  29. {
  30. x++;
  31. if(tab[n]==0)
  32. {
  33. y++;
  34. }
  35. n=n/10;
  36. }
  37. if(y==x)
  38. cout<<"TAK"<<endl;
  39.  
  40. else
  41. cout<<"NIE"<<endl;
  42.  
  43. y=0;
  44. x=0;
  45. }
  46. }
  47. return 0;
  48. }
Success #stdin #stdout 0.01s 7412KB
stdin
5
23
24
0
1
11
stdout
TAK
NIE
NIE
NIE
NIE