logo AlgoBeat OnlineJudge
登录 注册

#209251. [ICPC 2022 Jinan R] Tower

内存限制:512 MiB 时间限制:6000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

Prof. Pang built block towers with different heights. The -th tower has height .

Prof. Shou doesn't like these towers because of their arbitrary heights. He decides to , and then perform some (or none) of the following operations:

  • Choose a tower and increase its height by .
  • Choose a tower and decrease its height by .
  • Choose a tower and divide its height by . If the new height is not an integer, it is rounded down.

Prof. Shou can never choose a removed tower. If after an operation, the height of a tower will become , that operation is not allowed. Under these constraints, Prof. Shou can perform an arbitrary number of operations in arbitrary order.

Prof. Shou would like all the towers that are not removed to have the same heights. Please calculate the minimum number of operations to achieve this.

输入格式

The first line contains one integer , the number of test cases.

For each test case, the first line contains two integers , the number of towers, and the number of towers Prof. Shou should delete before performing the operations.

The next line contains integers , the initial heights of the towers.

输出格式

For each test case, output the minimum number of operations in one line.

样例

样例输入 1

3
2 0
2 6
5 0
1 2 3 4 5
5 3
1 2 3 4 5

样例输出 1

2
4
1