#C10848. Decode Secret Message
Decode Secret Message
Decode Secret Message
Given an integer k
and an array of integers, your task is to compute the sum of every k-th element in the array starting from the k-th
element. If we consider the array indexed starting from 1, you need to sum the elements located at positions \(k, 2k, 3k, \dots\) until the end of the array.
For example, if k = 3
and the array is [1, 2, 3, 4, 5, 6, 7, 8, 9]
, then the elements to sum are 3, 6, 9
and the answer is 18
.
inputFormat
The first line of input contains a single integer k
representing the step size. The second line contains a series of space-separated integers which form the array.
outputFormat
Output a single integer which is the sum of every k-th element in the array starting from the k-th
position.
3
1 2 3 4 5 6 7 8 9
18