当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6507:Problem H. Store The Matrix

题目描述
Given a matrix M with r rows and c columns. It is obviously that we need r × c elements to store this matrix.
However, for a specific matrix M, we may be able to represent M as “Matrix-chain multiplication” likes M = A1×A2 · · ·×An, where n ≥ 1 and each Ai
is a matrix with size ri×ci. Then we can use (${∑^n}_i=1$ ri×ci) elements to store {A1, A2 . . . , An} instead of storing M directly.
We want to know: if we represent M in the optimal way, how many elements are needed at least to store M?
输入解释
Input is given from Standard Input in the following format:
r c
$M_{1,1}$ $M_{1,2}$ ... $M_{1,c}$
$M_{2,1}$ $M_{2,2}$ ... $M_{2,c}$
...
...
...
$M_{r,1}$ $M_{r,2}$ ... $M_{r,c}$
Constraints
1 ≤ r, c ≤ 30
0 ≤ $M_{i,j}$ ≤ 1000(1 ≤ i ≤ r, 1 ≤ j ≤ c) (Note that although all $M_{i,j}$ are non-negative integers in the input,we think the element type is float number with infinity precision and can be negative) .
输出解释
Print one integer denotes the minimal number of elements needed
输入样例
3 3
1 0 1
0 0 0
1 0 1
输出样例
6
来自杭电HDUOJ的附加信息
Recommend

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6507

最后修改于 2020-10-25T23:31:56+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 262144/262144K(Java/Others)