已知矩阵的大小为−1 ∗ ,
计算123456。
0 = 30 , 1 = 35 , 2 = 15 , 3 =5 , 4 = 10,5 = 20 , 6 = 25,
用动态规划算法计算,写出矩阵加括弧次序。
A1A2 30x35x15=15750
A2A3 35x15x5=2625
A3A4 15x5x10=750
A4A5 5x10x20=1000
A5A6 10x20x25=5000
A1A2A3:
(A1(A2A3))=2625+30x35x5=7875
((A1A2)A3)=15750+30x15x5=18000
故A1A2A3=(A1(A2A3))=7875
A2A3A4:
(A2(A3A4))=750+35x15x10=6000
((A2A3)A4)=2625+35x5x10=4375
故A2A3A4=((A2A3)A4)=4375
A3A4A5:
(A3(A4A5))=1000+15x5x20=2500
(A3A4)A5))=750+15x10x20=3750
故A3A4A5=(A3(A4A5))=2500
A4A5A6:
(A4(A5A6))=5000+5x10x25=6250
(A4A5)A6))1000+5x20x25=3500
故A4A5A6=(A4(A5A6))=3500
A1A2A3A4:
A1(A2A3A4)=4375+30x35x15=13375
(A1A2)(A3A4)=15750+750+30x15x10=21000
(A1A2A3)A4=7875+30x5x10=9375
故A1A2A3A4=(A1A2A3)A4=9375
A2A3A4A5:
A2(A3A4A5)=2500+15x20x35=13000
(A2A3)(A4A5)=2625+1000+35x5x20=7125
(A2A3A4)A5=4375+35x10x20=11375
故A2A3A4A5=(A2A3)(A4A5)=7125
A3A4A5A6:
A3(A4A5A6)=3500+5x25x15=5375
(A3A4)(A5A6)=750+5000+15x10x25=9500
(A3A4A5)A6=2500+15x20x25=10000
故A3A4A5A6=A3(A4A5A6)==5375
省略步骤,按上述方法算出:
A1A2A3A4A5=11875
A2A3A4A5A6=10500
A1A2A3A4A5A6:
A1(A2A3A4A5A6)=30x35x25+10500=36750
(A1A2)(A3A4A5A6)=157580+5375+30x5x25=32375
(A1A2A3)(A4A5A6)=7875+3500+30x5x25=15125
(A1A2A3A4)(A5A6)=9375+5000+30x10x25=21875
(A1A2A3A4A5)A6=15375+30x20x25=26875
故A1A2A3A4A5A6=(A1A2A3)(A4A5A6)=15125
其中A1A2A3=(A1(A2A3)),(A4A5A6)=(A4(A5A6))。
最终为( (A1 (A2A3) ) (A4 (A5A6) ) )
计算过程图