Codeforces Round 967 (Div. 2) |
---|
Finished |
You are given a cyclic array $$$a_1, a_2, \ldots, a_n$$$.
You can perform the following operation on $$$a$$$ at most $$$n - 1$$$ times:
Your goal is to find the minimum number of operations needed to make all elements in $$$a$$$ equal.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 500$$$). The description of the test cases follows.
The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 100$$$) — the length of the array $$$a$$$.
The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_i \le n$$$) — the elements of array $$$a$$$.
For each test case, output a single line containing an integer: the minimum number of operations needed to make all elements in $$$a$$$ equal.
71131 2 331 2 255 4 3 2 161 1 2 2 3 388 7 6 3 8 7 6 361 1 4 5 1 4
0 2 1 4 4 6 3
In the first test case, there is only one element in $$$a$$$, so we can't do any operation.
In the second test case, we can perform the following operations to make all elements in $$$a$$$ equal:
It can be proven that we can't make all elements in $$$a$$$ equal using fewer than $$$2$$$ operations, so the answer is $$$2$$$.
Name |
---|