Input/Output: standard input/output

Cinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in the kitchen. Each bottle contains Li (0 ≤ Li ≤ 106) ounces of water and the maximum capacity of each is 109 ounces. To complete the task Cinderella has to pour the water between the bottles to fill them at equal measure.

Cinderella asks Fairy godmother to help her. At each turn Cinderella points out one of the bottles. This is the source bottle. Then she selects any number of other bottles and for each bottle specifies the amount of water to be poured from the source bottle to it. Then Fairy godmother performs the transfusion instantly.

Please calculate how many turns Cinderella needs to complete the Stepmother's task.

Input

The first line of input contains an integer number N (1 ≤ N ≤ 1000) — the total number of bottles.

On the next line integer numbers Li are contained (0 ≤ Li ≤ 106) — the initial amount of water contained in ith bottle.

Output

Output a single line with an integer S — the minimal number of turns Cinderella needs to complete her task.

Sample Input

Input
3
5 7 7
Output
2
Input
3
21 10 2012
Output
1
Input
1 
100
Output
0

链接

这个是队友想出来的 而且读题半天没猜出来是怎么回事(⊙﹏⊙)b

题意是说总共n瓶水 来回倒腾 直至水量相同 开始就一直纠结要是不能整除怎么办 出现分数就出现分数呗 只要最后水量相同就好了嘛

所以 找出水量大于平均数的瓶数 就是最终答案!

#include <iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int n,k,m,y,a,t;
struct node
{
   int score;
   int trait;
}num[10004];
int main()
{
    freopen("cin.txt","r",stdin);
    while(~scanf("%d%d",&n,&k))
    {
        for(int i=1;i<=n;i++)
        {
            scanf("%d%d",&num[i].score,&y);
            num[i].trait=0;
            while(y--)
            {
                scanf("%d",&a);
                num[i].trait+=(1<<(a-1));
                //printf("i=%d num[i].trait=%d\n",i+1,num[i].trait);
            }
        }
        scanf("%d",&m);
        while(m--)
        {
            scanf("%d%d",&a,&t);
            int tmp=0;
            while(t--)
            {
                scanf("%d",&y);
                tmp+=(1<<(y-1));
            }
            printf("tmp=%d\n",tmp);
            tmp=tmp^num[a].trait;
             printf("tmp=%d\n",tmp);
            tmp=-(~tmp);
            printf("tmp=%d\n",tmp);
            int maxn=num[a].score,pos=a;
            for(int i=1;i<=n;i++)
            {
                if(i==a) continue;
                int ans=0;
                ans=tmp^num[i].trait;
                if(ans==0) {
                    maxn=max(maxn,num[i].score);
                    pos=i;
                }
            }
            printf("%d\n",pos);
        }
        printf("\n");
    }
    return 0;
}

要是每次比赛做题都能这么顺利该多好==