Row-major vs Column-major
The numbers from to can be arranged into a matrix in either row-major or column-major order:
By swapping two entries at a time, at least swaps are needed to transform to .
Let be the minimal number of swaps needed to transform an matrix of to from row-major order to column-major order. Thus .
You are given that the sum of for is .
Find the sum of for .
行优先与列优先
到这些数可以按行优先或列优先的顺序填入一个矩阵中:
每次交换两个元素,至少需要次交换才能将转换为。
令为将一个包含到的矩阵从行优先顺序转换为列优先顺序所需的最少交换次数,因此。
已知对于所有,之和为。
求对于所有,之和。
Gitalking ...