# re: ZOJ 1251 - Box of Bricks 回复 更多评论
2008-09-08 19:35 by
这样就好了,没必要把上比他小的也加进来吧
#include<iostream>
using namespace std;
int main()
{int n,i,a[51],sum,ave,text,ans;
text=0;
while(cin>>n&&n!=0)
{text++;
sum=ans=0;
for(i=0;i<n;i++)
{cin>>a[i];
sum+=a[i];}
ave=sum/n;
for(i=0;i<n;i++)
{if(a[i]>ave)ans+=a[i]-ave;}
cout<<"Set #"<<text<<endl;
cout<<"The minimum number of moves is "<<ans<<"."<<endl<<endl;
}
return 0;
}