#K84897. Maximum Divisible Subsequence Sum
Maximum Divisible Subsequence Sum
Maximum Divisible Subsequence Sum
Given an array of integers and an integer ( k ), your task is to compute the maximum sum of a subsequence where every element in the subsequence is divisible by ( k ). In other words, you need to select some (or all) of the elements such that for every element ( x ) in the subsequence, ( x \mod k = 0 ), and then calculate the sum of these elements. If no element is divisible by ( k ), the answer is 0. Note that the subsequence does not need to be contiguous in the array.
inputFormat
The first line of input contains two 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 elements.
outputFormat
Output a single integer representing the maximum sum of a subsequence where each element is divisible by ( k ).## sample
7 5
10 5 9 15 20 6 25
75