#SP0000097. Bộ sinh số nguyên tố (Prime Generator)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Bộ sinh số nguyên tố (Prime Generator)
Prime Generator
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem Statement
Given integers and , list all prime numbers in the closed interval , including both endpoints. A prime is an integer greater than with exactly two distinct positive divisors. Output the primes in increasing order, one per line. If there are no primes in the interval, output nothing.
Skip all non-primes. If no primes exist, the result is an empty sequence.
Input
One line contains two integers and , the inclusive left and right endpoints of the interval.
Output
Print each prime in increasing order on its own line. If none exist, print nothing.
Subtasks
- Subtask 1 (20 points): ; .
- Subtask 2 (30 points): ; .
- Subtask 3 (50 points): ; .
Examples
Input
1 10
Output
2
3
5
7
Explanation
The number is not prime. The primes in are ; the other numbers greater than are composite. Therefore, print these four numbers in increasing order.