Discussion About T-Prime

This is Discussion thread about T-Prime

Time limit exceeded for test case 2 and 3. both are big integers.
any idea how to tackle them?

i think using hash table may help.

import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int []arr = new int [n] ;
for (int i = 0 ; i < n ; i++){
arr[i] = s.nextInt();
}
int count , i ;
for (i = 0 ; i < n ; i++){
count = 0 ;
for(int j = 1 ; j <= arr[i] ; j++){
if (arr[i] % j == 0){
count++ ;
}
}
if (count == 3){
System.out.println(“YES”);
}else{
System.out.println(“NO”);
}
}
}
}
What are the two test cases that are not passed by the above code ?

The logic is very simple :-
If the number is perfect square and its square root is prime then answer is “YES”
Else answer is “NO”.

but i am asking what are those two test cases that are not passed.