All problems

Problem 782

Count Even and Odd Elements

Easy · 10 pts · Array, Basics

Problem

Count how many numbers in the array are even and how many are odd, and print both counts. A number is even when it divides by 2 with no remainder; zero is even and negative numbers follow the same rule. Loop over the array once, keeping two counters, and remember to test x % 2 == 0 rather than x % 2 == 1 for negative numbers.

Input

The first line contains an integer N, the size of the array. The second line contains N space-separated integers A[0], A[1], ..., A[N-1].

Output

Print the number of even elements and the number of odd elements, separated by a space.

Constraints

1 <= N <= 100000; -10^9 <= A[i] <= 10^9

Example input

5
1 2 3 4 5

Example output

2 3

Explanation

In 1 2 3 4 5 the even numbers are 2 and 4 and the odd ones are 1, 3 and 5, so the answer is 2 3.

Every problem here can be used in a RelayTrixCode team match. Create a room.

Previous: Average of an Array Next: Count Occurrences of a Value