913. Row-major vs Column-major

The numbers from 1 to 12 can be arranged into a 3×4 matrix in either row-major or column-major order:

R=(123456789101112),C=(147102581136912)

By swapping two entries at a time, at least 8 swaps are needed to transform R to C.

Let S(n,m) be the minimal number of swaps needed to transform an n×m matrix of 1 to nm from row-major order to column-major order. Thus S(3,4)=8.

You are given that the sum of S(n,m) for 2nm100 is 12578833.

Find the sum of S(n4,m4) for 2nm100.

913. 优先填行或填列

112 间的整数可以通过 优先填行 的顺序排成 3×4 的矩阵 R,或通过 优先填列 的顺序排成 3×4 的矩阵 C

R=(123456789101112),C=(147102581136912)

若允许同时交换某矩阵中的两个元素,那么至少需要 8 次交换才能将 R 转换为 C

S(n,m) 为:将 1nm 间的整数通过优先填行、优先填列的顺序排成的 n×m 的矩阵分别记为 RC,把 R 转换为 C 最少需要交换元素的次数。因而 S(3,4)=8

你已知:对所有 2nm100S(n,m) 的和是 12578833

求:对所有 2nm100S(n4,m4) 的和。


这个链接 回到源站。

这个链接 回到详细版题目目录。