import java.util.*; public class ChainedMatrixMultiplication { static int min = Integer.MAX_VALUE; public static void main(String[] args){ String input = "2\n3\n3 2\n2 4\n4 2\n"+ "4\n20 2\n2 30\n30 12\n12 8\n"; Scanner s = new Scanner(input); int cases = s.nextInt(); for(int i=0;i" + total; } public static MatDim multiply(MatDim s1, MatDim s2){ int r = s1.rows; int c = s2.cols; int t = r * s1.cols * c + s1.total + s2.total; return new MatDim(r,c,t); } }