#K55052. Filter Multiples
Filter Multiples
Filter Multiples
You are given an array of positive integers and an integer X. Your task is to filter the array to output only those elements that are multiples of X. An integer \(A\) is considered a multiple of \(X\) if \(A \equiv 0 \; (\text{mod } X)\). This problem tests your ability to iterate over arrays and apply conditional logic based on mathematical properties.
inputFormat
The input is read from standard input (stdin) and consists of two lines:
- The first line contains two integers N and X separated by a space, where N is the number of elements in the array and X is the divisor.
- The second line contains N positive integers separated by spaces.
outputFormat
Output to standard output (stdout) the elements of the array that are multiples of X, separated by a single space. If no such elements exist, output an empty line.
## sample8 5
5 10 15 20 25 30 35 40
5 10 15 20 25 30 35 40