fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int t, n;
  13. boolean result = true;
  14. Scanner scanner = new Scanner(System.in);
  15. t = scanner.nextInt();
  16. for (int i = 0; i < t; i++) {
  17. n = scanner.nextInt();
  18. if (n < 2) {
  19. result = false;
  20. }
  21. else {
  22. for (int j = 2; j <= n / 2; j++) {
  23. if (n % j == 0) {
  24. result = false;
  25. break;
  26. }
  27. result= true;
  28. }
  29. }
  30. if(result==true)
  31. System.out.println("TAK");
  32. else
  33. System.out.println("NIE");
  34. }
  35. }
  36. }
Success #stdin #stdout 0.07s 2184192KB
stdin
3
11
4
1
stdout
TAK
NIE
NIE