T Prime Question Pracrice

We know that prime numbers are positive integers that have exactly two distinct positive divisors. Similarly, we’ll call a positive integer t Т-prime, if t has exactly three distinct positive divisors.

You are given an array of n positive integers. For each of them determine whether it is Т-prime or not.

2 of the test cases are giving run error

@duttrohan0302
maximum value of a[i] can be upto 10^12. You can’t create sieve of this big number of elements. That’s why it’s giving runtime error. You can solve this question by creating sieve till 10^6. Think about it.

Then what should we do?
Create a loop to check if it is a multiple of any of the primes till 10^6

See this code, I am trying to find if the sqrt of the number is a prime, its still not working

Save your code at http://ide.codingblocks.com/ then share here

@duttrohan0302
I already told you you cann’t create sieve upto max since max element can be upto 10^12. Create sieve upto 10^6.
I think you send the link of your previous code. there is no difference, please check

@duttrohan0302
I just check your latest submission. your code is correct but there is a small mistake. Value of array a[] can be upto 10^12 which can’t be stored in int. Change line 29 to ll ar[n]. All testcase will pass.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.