P22351 [CodeChef] MINNOTES
提高-
题目描述

Read problem statements in [Bengali], [Mandarin Chinese], [Russian], and [Vietnamese] as well.

You are the owner of a big company. You are so rich, that the government has allowed you to print as many notes as you want of any single value that you like. You also have peculiar behavioral traits and you often do things that look weird to a third person.

You have N employees, where the i-th employee has salary A_{i}. You want to pay them using a denomination that you create. You are also eco-friendly and wish to save paper. So, you wish to pay them using as few notes as possible. Find out the minimum number of notes required if you can alter the salary of at most one employee to any positive integer that you like, and choose the positive integer value that each note is worth (called its denomination).

Each employee must receive the exact value of his/her salary and no more.

------ Subtasks ------
Subtask #1 (100 points): Original constraints

------ Input Format ------

  • The first line contains an integer T, the number of test cases. Then the test cases follow.
  • The first line of each test case contains a single integer N.
  • The second line contains $N integers A_{1}, A_{2}, \ldots, A_{N}$, where A_{i} is the salary of the i-th employee.

------ Output Format ------

For each test case, output in a single line the answer to the problem.

------ Constraints ------

$1 ≤ T ≤ 12\cdot 10^{4}$
$1 ≤ N ≤ 10^{5}$
$1 ≤ A_{i} ≤ 10^{9}$
- The sum of $N$ over all test cases is at most $10^{6}$.

----- Sample Input 1 ------
3
3
1 2 3
3
8 4 2
2
2 2

----- Sample Output 1 ------
4
4
2

----- explanation 1 ------
Test Case $1$: We can change the salary of the third person to $1$ and use $1$ as the denomination. So in total we need $\frac{1}{1} + \frac{2}{1} + \frac{1}{1}$ = $1 + 2 + 1$ = $4$ notes.

Test Case $2$: We can change the salary of the first person to $2$ and use $2$ as the denomination. So in total we need $1 + 2 + 1$ = $4$ notes.

Test Case $3$: We can use $2$ as the denomination and we need not change the salary of any person. So in total we need $1 + 1$ = $2$ notes.

输入格式

见题面

输出格式

见题面

样例输入
3 3 1 2 3 3 8 4 2 2 2 2
样例输出
4 4 2