DMOPC '16 Contest 1 P1 - A New Chapter

View as PDF

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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 of integers, count the number of elements which share the parity of its index (-based).

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

Input Specification

The first line of the input contains the integer , denoting the number of elements in the array .

The next line of the input contains space-separated integers , denoting the elements of the array .

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

 Index Value ~0~ ~1~ ~2~ ~3~ ~4~ ~0~ ~1~ ~2~ ~3~ ~4~

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

• commented on April 17, 2018, 7:12 p.m.

was up

• commented on April 17, 2018, 7:12 p.m.

herro

• commented on April 15, 2018, 11:24 a.m.

I don't get this question. Should it just output number of array elements?

• commented on Oct. 11, 2016, 8:56 p.m.

What should the output be if none of the values match the index? Just 0?

• commented on Oct. 11, 2016, 9:01 p.m.

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

Your program should output the number of array elements which fulfill the condition.

• commented on Oct. 11, 2016, 9:00 p.m.

Yes.