Description
Matrix chain
Input (Standard input)
In first line, an integer N is given which is the number of matrices (1 ≤ N ≤ 100).
In the next line, N+1 integers are given where the ith integer is pi
Output (Standard output)
In first line, print minimum scalar multiplications to compute the product.
In the next line, print an optimal parenthesization of A1, A2, …, An. When printing it, just print the parenthesis, and the number of matrix without ‘A’, and every parenthesis and number must be separated by a space.
[Example]
Sample Input Sample Output
6
30 35 15 5 10 20 25 15125
( ( 1 ( 2 3 ) ) ( ( 4 5 ) 6 ) )
Description
1. File name must be Matrixchain.cpp
2. Make a comment of your student ID, name and class in the first line of the source code. ex) 2014601028_Honggildong_A
3. Please keep the source code that you have submitted for some unexpected accident.




Reviews
There are no reviews yet.