#K13276. Filtering Integers by Divisible Digit Sum
Filtering Integers by Divisible Digit Sum
Filtering Integers by Divisible Digit Sum
You are given a list of n integers and an integer X. Your task is to filter out all integers from the list whose digit sum is divisible by X. The digit sum of an integer is calculated by summing all its decimal digits.
For example, if the integer is 294 then the digit sum is \(2+9+4=15\). If \(15\) is divisible by X, the number is included in the output.
The order of the integers in the output must be the same as that of the input.
inputFormat
The first line contains two integers n and X separated by a space. The second line contains n integers separated by spaces.
outputFormat
Print the integers whose digit sum is divisible by X in their original order, separated by a single space. If no integer satisfies the condition, print an empty line.## sample
5 3
123 456 789 987 654
123 456 789 987 654
</p>