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 .
913. 优先填行或填列
至 间的整数可以通过 优先填行 的顺序排成 的矩阵 ,或通过 优先填列 的顺序排成 的矩阵 :
若允许同时交换某矩阵中的两个元素,那么至少需要 次交换才能将 转换为 。
记 为:将 至 间的整数通过优先填行、优先填列的顺序排成的 的矩阵分别记为 、,把 转换为 最少需要交换元素的次数。因而 。
你已知:对所有 , 的和是 。
求:对所有 , 的和。
点 这个链接 回到源站。
点 这个链接 回到详细版题目目录。