#SP0000278. Đếm số nguyên tố (Counting Primes)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Đếm số nguyên tố (Counting Primes)
Counting Primes
Source: Library Checker
Version: Phuoc Hung OJ Extended
Problem Statement
For a positive integer , let denote the number of prime numbers not exceeding . A prime number is an integer greater than with exactly two distinct positive divisors: and itself.
Compute , the number of primes satisfying .
Input
The only line contains a positive integer .
Output
Print one non-negative integer equal to the number of primes in .
Subtasks
- Subtask 1 (20 points): . Time limit: s.
- Subtask 2 (30 points): . Time limit: s.
- Subtask 3 (50 points): . Time limit: s.
Examples
Example 1
Input
10
Output
4
Explanation
Among the integers from through , precisely are prime. The remaining values are composite. Therefore the count is .
Example 2
Input
100
Output
25
Explanation
There are primes at most . The intervals –, –, –, and – contain primes respectively, yielding .
Example 3
Input
100000000000
Output
4118054813
Explanation
For , the exact prime-counting value is . Print 4118054813.