杭电2088
1 #include<cstdio> 2 int a[55]; 3 int main() 4 { 5 int Case=0,n,i,s,ans; 6 while(~scanf("%d",&n)&&n) 7 { 8 for(i=s=0; i<n; ++i) 9 { 10 scanf("%d",a+i); 11 s+=a[i]; 12 } 13 s/=n; 14 for(i=ans=0; i<n; ++i) 15 { 16 if(a[i]>s) 17 ans+=a[i]-s; 18 } 19 if(Case++) 20 printf("\n"); 21 printf("%d\n",ans); 22 } 23 }