Problem G: 985的数字难题

Problem G: 985的数字难题

Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 253 Solved: 82

SubmitStatusWeb BoardDescription
985有n个数,已知每次操作可以将其中不相同的两个数一个加一、一个减一,操作次数不限。
问他最多可以得到多少个相同的数。

Input
第一行输入一个整数t,代表有t组测试数据。
每组数据占两行,第一行输入一个n代表元素个数,下面一行输入n个整数a[]。
注:1 <= t <= 30,1 <= n <= 1e4,1 <= a[] <= 1e3。

Output
输出一个整数代表最多可以得到多少个相同的数。

Sample Input
2
3
1 1 1
2
2 3Sample Output
3
1HINT

SubmitStatusWeb BoardAnything about the Problems, Please Contact us
GPL2.0 2003


#include

int main()
{
    int t,n,i,a,s;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        s=0;
        for(i=1;i<=n;++i)
        {
            scanf("%d",&a);
            s+=a;
        }
        if(s/n*n==s)  printf("%d\n",n);
        else printf("%d\n",n-1);
    }
    return 0;
}

你可能感兴趣的:(暑假集训,contest)