#C12320. Prime Numbers in Range
Prime Numbers in Range
Prime Numbers in Range
Given two integers L and R, your task is to find all prime numbers in the interval \([L, R)\) and count them. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. You are encouraged to use an efficient \(O(\sqrt{n})\) algorithm to determine if a number is prime.
The output should consist of two lines: the first line lists the prime numbers in increasing order separated by a single space, and the second line displays the total count of prime numbers in the specified range.
inputFormat
The input consists of a single line containing two space-separated integers L and R (1 \(\leq\) L \(<\) R \(\leq\) 105), which denote the start (inclusive) and the end (exclusive) of the range.
outputFormat
Output two lines:
- The first line contains all the prime numbers in the interval \([L, R)\) separated by a single space. If there is no prime number, output an empty line.
- The second line contains the count of prime numbers found in that range.
10 20
11 13 17 19
4
</p>