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 ≤ 10^6) 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 ≤ 10^6) — 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
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 ≤ 10^6) — 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
题目意思是给你n个瓶子,每个瓶子中的水量都不一定,每次可以任选一个瓶子给别的瓶子倒任意量的水,问你要使每个瓶子里的水量一样需要的最少倒水次数
这是一道简单数学题,先求水量的平均数,只有比平均水量高的瓶子才能倒水,一个循环遍历即可得出结果
代码如下:
#include <stdio.h>
double p[1001];
int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
double a=0,b;
for(int i=1;i<=n;i++)
{
scanf("%lf",&p[i]);
a=p[i]+a;
}
b=a/n;
int jishu=0;
for(int i=1;i<=n;i++)
if(p[i]>b)
jishu+=1;
printf("%d\n",jishu);
}
return 0;
}