#44927: 各位有沒有注意到一個小細節?


yp11351280@yphs.tp.edu.tw (710-43)

學校 : 臺北市私立延平高級中學
編號 : 276272
來源 : [1.164.228.78]
最後登入時間 :
2025-01-31 16:17:49
c067. 00591 - Box of Bricks -- UVa591 | From: [203.72.178.1] | 發表日期 : 2024-12-26 17:17

#include<iostream>
#define MAX 50
using namespace std;
int main(){
    int n, j=1,sum,av,move,h[MAX];
    while(cin>>n,n!=0){
        sum=0;
        for(int i=0;i<n;i++) {cin>>h[i];sum+=h[i];}
        av=sum/n;
        move=0;
        for(int i=0;i<n;i++) if(h[i]>av) move+=(h[i]-av);
        cout<<"Set #"<<j++<<endl;
        cout<<"The minimum number of moves is "<<move<<"."<<endl<<endl; //不管單複數,都是moves
    }
}

 
ZeroJudge Forum