DMOPC '16 Contest 1 P1 - A New Chapter

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Xyene is going through a stressful week; It is yet another week of midterms, this time at university.

Unable to invest any more time into writing problems for the DMOPC, Xyene has offered you a position among the problemsetters of this DMCI-based contest, provided that you correctly answer the following skill-testing question:

Given an array A of integers, count the number of elements which share the parity of its index (0-based).

More colloquially, find the number of array elements which have the same remainder when divided by 2 (odd / even-ness) as its index.

Input Specification

The first line of the input contains the integer N (1 \le N \le 30), denoting the number of elements in the array A.

The next line of the input contains N space-separated integers A_i (0 \le A_i \le 100), denoting the elements of the array A.

Output Specification

Your program should output the number of array elements which have the same parity as its index on a single line by itself.

Sample Input

5
0 1 2 3 4

Sample Output

5

Explanation

\displaystyle A_0=0 \quad A_1 = 1 \quad A_2 = 2 \quad A_3 = 3 \quad A_4 = 4

All of the array elements are the same as their indices, so the answer is 5.


Comments

There are no comments at the moment.