fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int n=10000, i=1, k=2, d, z, u=1;
  7. bool tab[10001];
  8. int liczba[10001];
  9.  
  10. void tablica()
  11. {
  12. while (i<=n)
  13. {
  14. tab[i]=true;
  15. i++;
  16. }
  17.  
  18. while(k<=sqrt(n))
  19. {
  20. d=2*k;
  21. while (d<=n)
  22. {
  23. tab[d]=false;
  24. d=d+k;
  25. }
  26.  
  27. k++;
  28.  
  29. while (tab[k]==false)
  30. {
  31. k++;
  32. }
  33. }
  34. }
  35.  
  36. void wczytanie()
  37. {
  38.  
  39. for(int i=1; i<=z; i++)
  40. {
  41. cin >> liczba[i];
  42. }
  43. }
  44.  
  45. void monitor()
  46. {
  47.  
  48. while (u<=z)
  49. {
  50. if (liczba[u]==1)
  51. {
  52. cout << "NIE";
  53. }
  54. else
  55. {
  56.  
  57. if (tab[liczba[u]]==true)
  58. {
  59. cout << "TAK";
  60. }
  61. else
  62. {
  63. cout << "NIE"
  64. ; }
  65. }
  66. cout << endl;
  67. u++;
  68. }
  69. }
  70.  
  71.  
  72. int main()
  73. {
  74. tablica();
  75. cin >> z;
  76. wczytanie();
  77. monitor();
  78.  
  79. return 0;
  80. }
  81.  
Success #stdin #stdout 0s 15288KB
stdin
Standard input is empty
stdout
Standard output is empty