PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000067. Đếm số nguyên tố không vượt quá n (Prime Count)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm số nguyên tố không vượt quá n (Prime Count)
Prime Count
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given positive integer , count the primes in , including itself if prime. A prime exceeds and has exactly two distinct positive divisors, and itself. In particular, is not prime.
Input
One line contains integer .
Output
Print one integer: the number of primes not exceeding .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
5
Output
3
Explanation
In , the primes are . The number is not prime and is composite, so the count is 3.