Given two matrices with dimensions and , the cost of the usual multiplication algorithm is . For simplicity, let us consider that the cost is exactly .
Suppose that we must compute , where every is an matrix. Since the product of matrices is associative, we can choose the multiplication order. For example, to compute , we could either choose , with cost , or either choose , with cost , or three other possible orders.
Write a program to find the minimum cost of computing .
Input consists of several cases, each one with followed by the dimensions. Assume and .
For every case, print the minimum cost to compute the product of the matrices.
Author: Unknown
Translator: Salvador Roura
Generation: 2026-01-25T09:58:30.977Z
© Jutge.org, 2006–2026.
https://jutge.org