#include<iostream>
using namespace std;
int main()
{
int n, i, j = 1, s, b, c;
while(cin >> n)
{
s = c = 0;
if(n == 0)
break;
int a[n];
for(i=0;i<n;i++)
{
cin >> a[i];
s = s + a[i];
}
b = s/n;
for(i=0;i<n;i++)
{
if(a[i] > b)
{
c = c + (a[i] - b);
}
}
cout << "Set #" << j++ << endl;
cout << "The minimum number of moves is " << c << "."<< endl << endl;
}
return 0;
}
using namespace std;
int main()
{
int n, i, j = 1, s, b, c;
while(cin >> n)
{
s = c = 0;
if(n == 0)
break;
int a[n];
for(i=0;i<n;i++)
{
cin >> a[i];
s = s + a[i];
}
b = s/n;
for(i=0;i<n;i++)
{
if(a[i] > b)
{
c = c + (a[i] - b);
}
}
cout << "Set #" << j++ << endl;
cout << "The minimum number of moves is " << c << "."<< endl << endl;
}
return 0;
}
Comments
Post a Comment