You are given an integer N, and you need to find the number of Special Primes smaller than or equal to N.
Note:
1. A Prime number is a number that has only two factors 1 and N itself.
2. A Prime number P is known as Special Prime if it can
be represented as follows:
P = A^2 + B^4
where A and B are positive integers.
3. A and B should be greater than 0.
The first line of the input contains an integer 'T' denoting the number of test cases.
The first and only line of each test case consists of a single positive integer 'N'.
Output Format:
For each test case, print an integer that denotes the count of the number of Special Primes smaller than or equal to 'N' in a separate line.
The output of each test case should be printed in a separate line.
Note:
You don't have to print anything, and it has already been taken care of. Just Implement the given function.
1 <= T <= 100
1 <= N <= 5 * 10^5
Where 'T' represents the number of test cases, and 'N' is the given number.
Time Limit: 1 sec.
1
5
2
There are 2 special primes, 2 and 5.
Eg. 1^2 + 1^4 = 2, 2^2 + 1^4 = 5.
1
17
3
There are 3 special primes 2, 5 and 17.
Eg. 1^2 + 1^4 = 2, 2^2 + 1^4 = 5, 4^2 + 1^4 = 17.
Iterate over all primes and try to find if there exists a pair of values for A and B that form P equals to A^2 + B^4.
O(N^(7/4)), where N is the given positive integer.
As we are iterating from 1 to N. For each ‘i’ Checking primes take O(N^(½ )) order of time and finding A and B values requires O(N^(¼)) order of time.
O(1).
We are using constant extra memory.