Maven Securities TechOA #2
Count Numbers with Exactly 3 Divisors
Estimated MediumJudge-ready
Topics (AI-labelled)Bits & MathBinary Search
If a positive integer has exactly 3 positive divisors, it must be the square of a prime. For each given upper bound x, output how many such numbers do not exceed x.
This site adds a standard input/output protocol.
Input
The first line contains q (1 ≤ q ≤ 100000), followed by q lines with one integer x each (1 ≤ x ≤ 25000000000000).
Output
For each query, output on its own line the number of positive integers from 1 to x (inclusive) that have exactly 3 positive divisors.
Example 1
Input:
2
10
15
Output:
2
2
Example 2
Input:
1
100
Output:
4
Example 3
Input:
3
4
9
49
Output:
1
2
4
Editorial
Loading solution…