We have given a list of numbers (a1,a2,a3,....,an).
For each value in list we can choose a non-negative number and multiply it with our value. Performing this for all values in list.
Doing sum of all values after performing above operation , we do modulo of sum with a number M which is given.
What can be maximum possible outcome ?
Example:
list = [4,2,6] and M = 2
So, output = 0 { (4*a + 2*b + 6*c ) % 2 } (here as 4,2,6 all are even and 2 is smallest even number so..)
list = [7,3,2] and M = 10 output = 9 { (7*a + 3*b + 2*c) % 10 } ( taking a= 2 , b=1 and c = 1)
How to predict value of a , b , c ..... ?
NOTE - ALL numbers in list and M are positive integers .