#K3616. Sum Divisible Numbers

    ID: 25693 Type: Default 1000ms 256MiB

Sum Divisible Numbers

Sum Divisible Numbers

You are given an integer (N), an array of (N) integers, and an integer (k). Your task is to compute the sum of all elements in the array that are divisible by (k). For example, if the array is [2, 4, 5, 6, 9, 12] and (k = 3), the output should be (27) because 6, 9, and 12 are divisible by 3. This problem requires careful handling of input and output using standard input and output streams.

inputFormat

The input is read from standard input (stdin). The first line contains an integer (N) representing the number of elements in the array. The second line contains (N) space-separated integers. The third line contains the integer (k).

outputFormat

Print a single integer to the standard output (stdout), which is the sum of all elements that are divisible by (k).## sample

6
2 4 5 6 9 12
3
27

</p>