dynamic-programming Matrix Chain Multiplication