#C2787. Minimum Operations to Equalize Array
Minimum Operations to Equalize Array
Minimum Operations to Equalize Array
Problem Description: Given an array of integers, determine the minimum number of operations required to make all elements of the array equal. In each operation, you are allowed to change all elements to any chosen number. Consequently, if the array is not already uniform, a single operation is sufficient to equalize it; if the array elements are already the same, no operation is needed.
Formal Description: For an array \(a = [a_1, a_2, \ldots, a_n]\), output \(0\) if \(a_1 = a_2 = \cdots = a_n\), and \(1\) otherwise.
inputFormat
Input Format:
- The first line contains a single integer \(T\) (the number of test cases).
- For each test case:
- The first line contains an integer \(n\) (the size of the array).
- The second line contains \(n\) space-separated integers representing the array elements.
outputFormat
Output Format:
- For each test case, output a single integer on a new line: \(0\) if the array elements are all equal, otherwise \(1\).
3
3
1 2 3
2
3 4
5
1 1 1 1 1
1
1
0
</p>