Time limit per test
2 seconds
Memory limit per test
256 megabytes
Input
Standard Input
Output
Standard output
Polycarpus has an array, consistingNIntegersA1, bytes,A2, middle..., middle ,...,AN.
Polycarpus likes it when numbers in an array match. That's why he wants the array to have as your equal numbers as possible. For that polycarpus performs the following Operation multiple times:
- He chooses two elements of the arrayAI,AJ(I =J);
- He simultaneously increases numberAIBy 1 and
Decreases numberAJBy 1,
That is, executesAISignature = SignatureAIBetween + between 1 andAJSignature = SignatureAJAccept-encoding 1.
The given operation changes exactly two distinct array elements. polycarpus can apply the described operation an infinite number of times.
Now he wants to know what maximum number of equal array elements he can get if he performs an arbitrary number of such operation. Help polycarpus.
Input
The first line contains integerN(1 digit ≤ DigitNLimit ≤ limit 105)
-The array size. The second line contains space-separated IntegersA1, bytes,A2, middle..., middle ,...,AN(|AI| Limit ≤ limit 104)
-The original array.
Output
Print a single integer-the maximum number of equal array elements he can get if he performs an arbitrary number of the given operation.
Sample test (s) Input
22 1
Output
1
Input
31 4 1
Output
3
Explanation: considering that the addition and subtraction operations are actually the conversion of numbers, you only need to determine whether the sum of all numbers can be divisible by N. If the sum of all numbers can be divisible, n is output, when division is not allowed, we can use the remainder as a separate number. At this time, there are n-1 identical numbers, and N-1 is output.
#include <iostream>#include <cstdio>#include <cstdlib>#include <cmath>#include <cstring>#include <string>#include <algorithm>using namespace std;int main() {int n,i,a;int sum;sum=0;scanf("%d",&n);for(i=0;i<n;i++){scanf("%d",&a);sum+=a;}if(sum%n==0){printf("%d\n",n);}else{printf("%d\n",n-1);}return 0;}