You have an array containing N elements. At any move, you choose two indices i and j ( 0 <= i, j < N and i != j ) and increment value at one index and decrement value at other index. You can make this move any number of times. What is the maximum number of elements which can have the same value (after any number of moves) ?
Input
First line consists of T, the number of test cases. (1 <= T <= 100)
T sets follow. Each set contains N, the number of elements in the array, in the first line. (1 <= N <= 100000)
Next line of each set consists of N space separated integers (0 <= value <= 100000)
Output
Output T lines each containing the required answer.
Example
Input: 1 4 1 2 3 4 Output: 3
水题,,判断和是否被n整除
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#include <list>
const int maxn=5e2+10;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int T;
int n;
ll sum =0;
ll t;
int main()
{
cin >> T;
while(T--)
{
cin >>n;
int t1 = n;
while(t1--)
{
cin >>t;
sum+=t;
}
if(sum%n==0)
{
cout << n<<endl;
}
else
cout << n-1<<endl;
}
return 0;
}