#include<stdio.h>
int main()
{
int n;
int i,j,k,l,m,count,total,ave;
int a[109];
m=0;
while(scanf("%d",&n)==1)
{
if(n==0)
break;
total=0;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
total=total+a[i];
}
ave=total/n;
count=0;
for(j=0;j<n;j++)
{
if(a[j]>ave)
count=count+(a[j]-ave);
}
printf("Set #%d\n",++m);
printf("The minimum number of moves is %d.\n",count);
}
return 0;
}
int main()
{
int n;
int i,j,k,l,m,count,total,ave;
int a[109];
m=0;
while(scanf("%d",&n)==1)
{
if(n==0)
break;
total=0;
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
total=total+a[i];
}
ave=total/n;
count=0;
for(j=0;j<n;j++)
{
if(a[j]>ave)
count=count+(a[j]-ave);
}
printf("Set #%d\n",++m);
printf("The minimum number of moves is %d.\n",count);
}
return 0;
}
No comments:
Post a Comment