Problem Description
Description
985 has n numbers. It is known that in each operation, he can add one to one of two different numbers and subtract one from the other, with no limit on the number of operations.
What is the maximum number of equal numbers he can obtain?
Input
The first line contains an integer t, representing t groups of test data.
Each test case occupies two lines. The first line contains an integer n representing the number of elements, and the next line contains n integers a[].
Note: 1 <= t <= 30, 1 <= n <= 1e4, 1 <= a[] <= 1e3.
Output
Output an integer representing the maximum number of equal numbers that can be obtained.
Sample Input
| |
Sample Output
| |
Problem Analysis
Because adding one and subtracting one leave the total unchanged,
it follows that the final number is related to sum/n, i.e., the average.
When sum%n==0, it is always possible to eventually turn them into n equal numbers.
Otherwise, there will inevitably be an extra sum-sum/n*n at the end,
so in the end they can only be turned into n-1 equal numbers.
| |
Problem URL: ZZULI 1898 985 Number Problem