fork(3) download
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. bool czy_pierwsza(int n)
  7. {
  8. if (n<=2)
  9. return false;
  10. for (int i=2; i*i<=n; i++)
  11. if(n%i==0) return false;
  12. return true;
  13. }
  14.  
  15. int main()
  16. {
  17. int test, liczba;
  18. cin >> test;
  19. for (int i=1; i<=test; i++)
  20. {
  21. cin >> liczba;
  22. if (czy_pierwsza(liczba))
  23. cout << "TAK"<< endl;
  24. else
  25. cout << "NIE" <<endl;
  26. }
  27. return 0;
  28. }
Success #stdin #stdout 0s 16064KB
stdin
3
11
2
4
stdout
TAK
NIE
NIE