PE了n次……

http://acm.hdu.edu.cn/showproblem.php?pid=2088

2010-10-29 16:30:56 Accepted 2088 0MS 180K 410 B G++ rll
代码
1 #include<stdio.h>
2  #define N 51
3 int main()
4 {
5 int n,a[N],i,h,sum,flag=0;
6 while(scanf("%d",&n)!=EOF&&n)
7 {
8 if(flag)
9 printf("\n");
10 for(h=0,i=1;i<=n;i++)
11 {
12 scanf("%d",&a[i]);
13 h+=a[i];
14 }
15 h/=n;sum=0;
16 for(i=1;i<=n;i++)
17 {
18 if(a[i]>h)
19 sum+=a[i]-h;
20 }
21 printf("%d\n",sum);
22 flag=1;
23 }
24 return 0;
25 }

 

posted on 2010-10-29 16:38  role  阅读(493)  评论(0编辑  收藏  举报