#C5609. Count Multiples
Count Multiples
Count Multiples
You are given an integer N
, an integer K
, and an array of N
integers. Your task is to count how many elements in the array are multiples of K
. In other words, count the number of integers a in the list such that $$a\mod K = 0$$.
Example:
If N = 5
, K = 2
and the list is [4, 3, 5, 2, 6], then the answer is 3 because 4, 2, and 6 are multiples of 2.
Input is taken from standard input (stdin) and the result should be printed to standard output (stdout).
inputFormat
The first line of input contains two space-separated integers N
and K
where N
is the number of elements in the array and K
is the divisor.
The second line contains N
space-separated integers representing the array.
outputFormat
Output a single integer — the count of numbers in the array that are multiples of K
. In mathematical terms, output the number of indices i such that $$A_i \mod K = 0$$.
5 2
4 3 5 2 6
3