#K41657. Find Even Sum Pair
Find Even Sum Pair
Find Even Sum Pair
Given an integer \( n \) and an array of \( n \) integers, your task is to find a pair of indices \( (i, j) \) (using 1-based indexing) such that the sum of the numbers at these indices is even. In other words, you need to find indices \( i \) and \( j \) for which \( arr[i-1] + arr[j-1] \) is even.
The strategy is as follows: if there are at least two even numbers in the array, output the first two indices corresponding to even values. Otherwise, output the first two indices corresponding to odd values. It is guaranteed that exactly one valid pair exists.
Note: You are required to read input from stdin
and print the result to stdout
. Use the following input format:
- The first line contains an integer \( n \).
- The second line contains \( n \) space-separated integers.
The output should be two integers \( i \) and \( j \) separated by a space.
inputFormat
The first line of input contains a single 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 two space-separated integers \( i \) and \( j \), denoting the indices (1-based) of the two numbers whose sum is even. If there is at least one pair of even numbers, choose the first two even numbers; otherwise, choose the first two odd numbers.
## sample5
1 3 5 2 8
4 5