Count many primes quickly with short code
Time limit5sMemory limit1024 MB
For each test case, count the primes less than or equal to N, where N can be up to 10^12 when there is only one test case.
- Level
Medium7 of 10
- Topics
- Number theory, Math, Dynamic programming
- Solved
- No attempts yet
Input
The first line contains the number of test cases . ()
Each test case is given on its own line as a single positive integer .
At least one of the following holds.
- ,
- ,
- ,
Output
For each test case, print on its own line the number of primes less than or equal to .