#C4882. Longest Composite Subarray
Longest Composite Subarray
Longest Composite Subarray
Your task is to find the length of the longest contiguous subarray in which every number is a composite number. A composite number is defined as an integer \( x \) such that \( x > 1 \) and there exists an integer \( i \) with \( 2 \le i \le \sqrt{x} \) for which \( i \) divides \( x \) evenly.
For example, consider the array [4, 6, 8, 7, 9, 10]. The numbers 4, 6, 8, 9, 10 are composite, while 7 is prime, breaking the subarray. The longest contiguous block of composite numbers is [4, 6, 8] with length 3.
You are required to read the input from standard input (stdin
) and output your result to standard output (stdout
).
inputFormat
The input consists of two lines:
- The first line contains an integer \( n \) representing the number of elements in the array.
- The second line contains \( n \) space-separated integers representing the elements of the array.
outputFormat
Output a single integer which is the length of the longest contiguous subarray consisting entirely of composite numbers.
## sample6
4 6 8 7 9 10
3