#C5825. Prime Counting and Maximum Prime Gap
Prime Counting and Maximum Prime Gap
Prime Counting and Maximum Prime Gap
Given two integers \(X\) and \(Y\) (with \(X \le Y\)), count the number of prime numbers in the closed interval \([X, Y]\). Additionally, if there are at least two primes in the interval, determine the maximum gap between consecutive prime numbers. The prime gap between two consecutive primes \(p_i\) and \(p_{i+1}\) is defined as:
[ \text{gap} = p_{i+1} - p_i ]
If there is less than two prime numbers, the maximum gap is defined as 0. This problem challenges you to efficiently search for primes and then compute the required metrics.
inputFormat
The input is provided on a single line via standard input. It contains two integers \(X\) and \(Y\) separated by a space.
Constraints (for example purposes):
- 2 \(\le\) X \(\le\) Y \(\le\) 1000
outputFormat
The output should be printed to standard output in a single line containing two integers separated by a space. The first integer is the count of prime numbers in the range \([X, Y]\) and the second is the maximum gap between any two consecutive primes (or 0 if there are fewer than two primes).
## sample10 30
6 6