#SP0000100. Liệt kê số nguyên tố trên khoảng (Prime Intervals)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Liệt kê số nguyên tố trên khoảng (Prime Intervals)
Prime Intervals
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.
A prime equal to the left or right endpoint must also be printed because both endpoints are included.
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
2 10
Output
2
3
5
7
Explanation
In , the numbers are prime, whereas are composite. Print , , , and on separate lines.