PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000047. Đếm số nguyên tố không vượt quá N (Eratosthenes Prime Numbers)
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 (Eratosthenes Prime Numbers)
Eratosthenes Prime Numbers
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , determine how many primes are less than or equal to . A prime must be greater than and have exactly two positive divisors.
Input
One line containing the integer .
Output
Print one integer: the number of primes in .
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
11
Output
5
Explanation
The primes not exceeding are , so the count is . The number is composite and is not counted.