#C4655. K Consecutive Odds
K Consecutive Odds
K Consecutive Odds
You are given an array of integers and an integer \( k \). Your task is to determine whether there is a subarray of \( k \) consecutive numbers in which every number is odd.
More formally, given an array \( A = [a_1, a_2, \dots, a_n] \) and an integer \( k \), check if there exists an index \( i \) (1-based indexing) such that \( a_i, a_{i+1}, \dots, a_{i+k-1} \) are all odd numbers. If such an index exists, print True
; otherwise, print False
.
Note: The input format uses standard input (stdin) and output format uses standard output (stdout).
inputFormat
The first line of input contains two space-separated integers, \( n \) and \( k \), where \( n \) is the number of elements in the array and \( k \) is the number of consecutive odd numbers required.
The second line contains \( n \) space-separated integers representing the array \( A \).
outputFormat
Output a single line: True
if there exists a subarray of \( k \) consecutive odd numbers; otherwise, output False
.
5 3
1 2 3 4 5
False