

If ‘N’ = 4 and ‘ARR’ = [3, 5, 4, 2].
3 has 2 factors, which are 1 and 3.
5 has 2 factors, which are 1 and 5.
4 has 3 factors, which are 1, 2 and 4.
2 has 2 factors, which are 1 and 2.
Hence, the answer is [0, 0, 1, 0].
The first line contains a single integer ‘T’ representing the number of test cases.
The first line of each test case contains a single integer ‘N’ denoting the number of elements in the array.
The next line contains ‘N’ space-separated integers denoting the elements of array ‘ARR’.
For each test case, print an array containing 0 and 1 where 1 is present if the number ‘ARR[index]’ has exactly 3 factors. Otherwise, 0 is present.
Print the output of each test case in a separate line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
1 <= N <= 10^6
1 < ARR[index] <= 10^12
Time Limit: 1 second
In this approach, we will implement a function in which we have to pass an integer, and for each integer passed, the function returns the number of factors of that number. So we iterate over the input array ARR, and we pass each ARR[index] to this function. If it returns 3, the result[index] is set to 1. Otherwise, it is set to 0. In the end, we will return the array result.
In this approach, we will make a sieve array that maintains whether that particular index is a prime number or not. If the index is a prime number, then the sieve[index] is equal to 1. Otherwise, sieve[index] is equal to 0.
Now, after this, we have to traverse the input array ARR