SPOJ - MKEQUAL E - Make them equal ! 水题

You have an array containing N elements. At any move, you choose two indices i and j ( 0 <= ij < 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;	
} 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值