#C8470. Sum of Multiples
Sum of Multiples
Sum of Multiples
Given an integer (N) representing the number of integers, an integer (K), and a list of (N) integers, your task is to calculate the sum of all numbers in the list that are multiples of (K). A number (a) is considered a multiple of (K) if there exists an integer (x) such that (a = K \times x).
For example, when (N = 5), (K = 3), and the list is [1, 6, 4, 9, 12], the numbers 6, 9, and 12 are multiples of 3. Their sum is (6 + 9 + 12 = 27).
inputFormat
The input is given via standard input (stdin). The first line contains two integers (N) and (K) separated by a space. The second line contains (N) integers separated by spaces.
outputFormat
Print a single integer to standard output (stdout) representing the sum of all numbers in the list that are multiples of (K).## sample
5 3
1 6 4 9 12
27