PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#SP0000040. Liệt kê số nguyên tố (Print 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
Liệt kê số nguyên tố (Print Prime Numbers)
Print Prime Numbers
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
Given an integer , find every prime number not greater than and list them in increasing order. A prime is an integer greater than whose only positive divisors are and itself.
Input
One line containing the integer .
Output
Print the primes from through in ascending order, on one line, separated by spaces.
Subtasks
- Subtask 1 (20 points): .
- Subtask 2 (30 points): .
- Subtask 3 (50 points): .
Examples
Input
10
Output
2 3 5 7
Explanation
For , the primes are . The integers are composite, so the program prints 2 3 5 7 in increasing order.