0

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 .

  • I can't understand that solution. – learner-coder Apr 07 '19 at 11:11
  • The solution shows the maximum possible outcome is $M$ minus the largest factor in common among all of the $a_i$ and $M$. The answer provided there explains why this is the maximum value and a way to achieve it. I suggest you leave a comment to the other answer asking about what specifically you don't understand. – John Omielan Apr 07 '19 at 11:39
  • @Jagan_ I agree, feel free to ask anything about the solution. Happy to help. – eudes Apr 11 '19 at 08:04

0 Answers0