title: Minimum Operations Make Gcd Array Multiple K
signature: class Solution {
  
      public Integer minimumOperationsMakeGcdArrayMultipleK(ArrayList<Integer> a, Integer n, Integer k) {
source_py: def minimum_operations_make_gcd_array_multiple_k(a, n, k):
      result = 0
      for i in range(n):
          if ((a[i] != 1) and (a[i] > k)):
              result = (result + min((a[i] % k), (k - (a[i] % k))))
          else:
              result = ((result + k) - a[i])
      return result
source_cpp: int minimum_operations_make_gcd_array_multiple_k(vector<int> a, int n, int k) {
    int result = 0;
    for ( int i = 0;
    i < n;
    ++ i ) {
      if ( a [ i ] != 1 && a [ i ] > k ) {
        result = result + min ( a [ i ] % k, k - a [ i ] % k );
      }
      else {
        result = result + k - a [ i ];
      }
    }
    return result;
  }
question_info.extension: java
question_info.entry_fn_name: minimumOperationsMakeGcdArrayMultipleK
question_info.entry_cls_name: Solution
question_info.test_list: [{"idx": 0, "outputs": 19, "inputs": {"a": [3, 7, 27, 32, 36, 37, 44, 48, 50, 64, 86], "n": 5, "k": 10}}, {"idx": 1, "outputs": 130, "inputs": {"a": [-22, 6, -20, 60, -74, 98, 52, -22], "n": 5, "k": 4}}, {"idx": 2, "outputs": 661, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 23, "k": 29}}, {"idx": 3, "outputs": 43, "inputs": {"a": [77, 11, 51, 11, 84, 79, 43, 12, 14, 50, 15, 6, 85, 32, 74, 49, 7, 2, 58], "n": 9, "k": 17}}, {"idx": 4, "outputs": 778, "inputs": {"a": [-90, -66, -64, -58, -46, -44, -32, -30, -30, -22, -18, -14, 12, 12, 18, 34, 44, 60, 70, 70, 74, 76, 86, 98, 98], "n": 12, "k": 22}}, {"idx": 5, "outputs": 1096, "inputs": {"a": [1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1], "n": 36, "k": 31}}, {"idx": 6, "outputs": 28, "inputs": {"a": [9, 22, 27, 27, 37, 53, 53, 56, 63, 73, 76, 81, 82], "n": 10, "k": 11}}, {"idx": 7, "outputs": 479, "inputs": {"a": [-46, 60, 80, 80, 42, -98, 30, -48, 4, -32, -78, 40, 52, 26, 88, 4, 22, 62, 88, -94, 2, 0, 58, 38, 52, -50, -52, 58, -62, 30, -38, -8, -82, -66], "n": 18, "k": 19}}, {"idx": 8, "outputs": 413, "inputs": {"a": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], "n": 19, "k": 22}}, {"idx": 9, "outputs": 51, "inputs": {"a": [42, 69, 93, 82, 8, 23, 73, 1, 77, 39, 49, 4, 95, 85], "n": 12, "k": 13}}]
question_info.test_code: import static java.util.Map.entry;  
  import java.util.*;
  import java.lang.*;
  // TESTING CODE 
  // ============================================
  class QuestionEvaluator {
      public static String validateSolution(ArrayList<Integer> a, Integer n, Integer k, Integer expected){
          try{
              Driver driver = new Driver();
              if (driver.run(a, n, k,expected)){
                  return "PASSED";
              }
              return "FAILED";
              
          } catch (Exception exception_obj){
              return exception_obj.getClass().getSimpleName();
          }
  
      }
      public static void main(String[] args) {
          String result;
          result = validateSolution(new ArrayList<>(Arrays.asList(3, 7, 27, 32, 36, 37, 44, 48, 50, 64, 86)), 5, 10, 19);
          System.out.println(String.format("%s%s","TEST-0...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-22, 6, -20, 60, -74, 98, 52, -22)), 5, 4, 130);
          System.out.println(String.format("%s%s","TEST-1...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 23, 29, 661);
          System.out.println(String.format("%s%s","TEST-2...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(77, 11, 51, 11, 84, 79, 43, 12, 14, 50, 15, 6, 85, 32, 74, 49, 7, 2, 58)), 9, 17, 43);
          System.out.println(String.format("%s%s","TEST-3...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-90, -66, -64, -58, -46, -44, -32, -30, -30, -22, -18, -14, 12, 12, 18, 34, 44, 60, 70, 70, 74, 76, 86, 98, 98)), 12, 22, 778);
          System.out.println(String.format("%s%s","TEST-4...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1)), 36, 31, 1096);
          System.out.println(String.format("%s%s","TEST-5...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(9, 22, 27, 27, 37, 53, 53, 56, 63, 73, 76, 81, 82)), 10, 11, 28);
          System.out.println(String.format("%s%s","TEST-6...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(-46, 60, 80, 80, 42, -98, 30, -48, 4, -32, -78, 40, 52, 26, 88, 4, 22, 62, 88, -94, 2, 0, 58, 38, 52, -50, -52, 58, -62, 30, -38, -8, -82, -66)), 18, 19, 479);
          System.out.println(String.format("%s%s","TEST-7...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1)), 19, 22, 413);
          System.out.println(String.format("%s%s","TEST-8...",result));    
      
          result = validateSolution(new ArrayList<>(Arrays.asList(42, 69, 93, 82, 8, 23, 73, 1, 77, 39, 49, 4, 95, 85)), 12, 13, 51);
          System.out.println(String.format("%s%s","TEST-9...",result));    
      
      }
  }
  
  class Driver{
      public boolean run(ArrayList<Integer> a, Integer n, Integer k, Integer expected){
  
          PLACEHOLDER_CLS_NAME sol = new PLACEHOLDER_CLS_NAME();
          return validateSolution(sol.PLACEHOLDER_FN_NAME(a, n, k),expected);
      }
      
      public boolean validateSolution(Integer actual, Integer expected){
          return actual.equals(expected);
      }
  }
  
  
  // SOLUTION CODE
  // ============================================
  PLACEHOLDER_CODE_BODY
question_info.test_case_ids: 0 1 2 3 4 5 6 7 8 9
question_info.commands: java __FILENAME__