← ~/bài tập
P2007

Count the Primes

Medium
// Đề bài
Given an integer n, count how many prime numbers are less than or equal to n.
// Đầu vào
A single integer n (1 <= n <= 10^6).
// Đầu ra
The number of primes not greater than n.
// Gợi ý
A sieve of Eratosthenes counts all primes up to n in O(n log log n).
// Ví dụ
Đầu vào ví dụ
10
Đầu ra ví dụ
4
// Thông tin bài tập
Độ khóMedium
Tỉ lệ chấp nhận80%
Giới hạn thời gian1000 ms
Giới hạn bộ nhớ65536 KB
Được chấp nhận8