PKU 1477 Box of Bricks
http://poj.org/problem?id=1477
n個の箱が積み上げられたタワーがある。
このタワーの高さを平均化するのに必要な最小の箱の移動個数を答える問題。
易。
出力形式に注意した。
int in[50]; main(){ int n; int se=0; while(cin>>n,n){ ++se; cout<<"Set #"<<se<<endl; int sum=0; rep(i,n){ cin>>in[i]; sum+=in[i]; } int ans=0; sum/=n; rep(i,n){ if(sum>=in[i])ans+=sum-in[i]; } cout<<"The minimum number of moves is "<<ans<<'.'<<endl<<endl;; } }