#C4735. Sum of Even Numbers and Product of Odd Numbers

    ID: 48306 Type: Default 1000ms 256MiB

Sum of Even Numbers and Product of Odd Numbers

Sum of Even Numbers and Product of Odd Numbers

Problem Description

You are given an array of integers. Your task is to compute two values:

  • The sum of all even numbers in the array.
  • The product of all odd numbers in the array. If there is no odd number, the product is defined as 1.

In mathematical notation, let \( A = \{a_1, a_2, \ldots, a_n\} \) be the array. Then you must compute:

  • The even sum: \[ S_{even} = \sum_{a_i \in A,\; a_i \,\%\,2=0} a_i \]
  • The odd product: \[ P_{odd} = \begin{cases} \prod_{a_i \in A,\; a_i \,\%\,2\neq 0} a_i, & \text{if at least one odd exists}\\ 1, & \text{otherwise} \end{cases} \]

The output should present both computed values separated by a space.

inputFormat

The first line of input contains a single integer n which is 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 line containing two integers: the sum of all even numbers and the product of all odd numbers, separated by a space.

## sample
5
1 2 3 4 5
6 15

</p>