<gouthampradhan>dynamic_programming_LargestSumOfAverages_1.java
public double largestSumOfAverages(int[] A, int K) {
    double[][] dp = new double[K][A.length];
    for (int i = dp[0].length - 1; i >= 0; i--) {
      dp[0][i] = A[i];
      if (i + 1 < dp[0].length) {
        dp[0][i] += dp[0][i + 1];
      }
    }
    for (int i = dp[0].length - 1, j = 1; i >= 0; i--, j++) {
      dp[0][i] = dp[0][i] / j;
    }
    for (int i = dp[0].length - 1; i >= 0; i--) {
      for (int j = 1; j < dp.length; j++) {
        double sum = 0.0D;
        for (int k = i, c = 1; k < dp[0].length; k++, c++) {
          sum += A[k];
          if (k + 1 < dp[0].length) {
            double avg = sum / c;
            avg += dp[j - 1][k + 1];
            dp[j][i] = Math.max(dp[j][i], avg);
          }
        }
      }
    }
    return dp[K - 1][0];
  }
public double sample_funcname ( int [ ] var_0 , int var_1 ) {
  double [ ] [ ] var_3 = new double [ var_1 ] [ var_0 . length ] ;
  for ( int var_6 = var_3 [ 0 ] . length - 1 ;
  var_6 >= 0 ;
  var_6 -- ) {
    var_3 [ 0 ] [ var_6 ] = var_0 [ var_6 ] ;
    if ( var_6 + 1 < var_3 [ 0 ] . length ) {
      var_3 [ 0 ] [ var_6 ] += var_3 [ 0 ] [ var_6 + 1 ] ;
    }
  }
  for ( int var_6 = var_3 [ 0 ] . length - 1 , var_7 = 1 ;
  var_6 >= 0 ;
  var_6 -- , var_7 ++ ) {
    var_3 [ 0 ] [ var_6 ] = var_3 [ 0 ] [ var_6 ] / var_7 ;
  }
  for ( int var_6 = var_3 [ 0 ] . length - 1 ;
  var_6 >= 0 ;
  var_6 -- ) {
    for ( int var_7 = 1 ;
    var_7 < var_3 . length ;
    var_7 ++ ) {
      double var_9 = 0.0D ;
      for ( int var_10 = var_6 , var_11 = 1 ;
      var_10 < var_3 [ 0 ] . length ;
      var_10 ++ , var_11 ++ ) {
        var_9 += var_0 [ var_10 ] ;
        if ( var_10 + 1 < var_3 [ 0 ] . length ) {
          double var_12 = var_9 / var_11 ;
          var_12 += var_3 [ var_7 - 1 ] [ var_10 + 1 ] ;
          var_3 [ var_7 ] [ var_6 ] = Math . max ( var_3 [ var_7 ] [ var_6 ] , var_12 ) ;
        }
      }
    }
  }
  return var_3 [ var_1 - 1 ] [ 0 ] ;
}
