fork(7) download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int n,a,c;
  5. int main()
  6. {
  7. cin>>n;
  8. int *tab;
  9. tab=new int[n];
  10. for (int i=0; i<n; i++)
  11. {
  12. cin>>a;
  13. tab[i]=a;
  14. }
  15. for(int i=0; i<n; i++)
  16. {
  17.  
  18. if(tab[i]<2) cout<<"NIE"<<endl;
  19. else if(tab[i]==2||tab[i]==3||tab[i]==5||tab[i]==7) cout<<"TAK"<<endl;
  20. else
  21. {
  22. for(int j=2; j*j<=tab[i]; j++)
  23. {
  24. c=sqrt(tab[i]);
  25. if(tab[i]%j==0 || tab[i]%c == 0)
  26. {
  27. cout<<"NIE"<<endl;
  28. break;
  29. }
  30. else
  31. {
  32. cout<<"TAK"<<endl;
  33. break;
  34. }
  35. }
  36.  
  37. }
  38. }
  39. delete [] tab;
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 16064KB
stdin
13
1
2
3
4
5
6
7
8
9
11
121
10
144
stdout
NIE
TAK
TAK
NIE
TAK
NIE
TAK
NIE
NIE
TAK
NIE
NIE
NIE