题目: |
var a:array[1..100] of longint;
i,j,n,k,tot,ave,min:longint;
begin
readln(n);
tot:=0;
for i:=1 to n do begin
read(a[i]);
tot:=tot+a[i];
end;
ave:=tot div n;
min:=0;
i:=1;
repeat
if a[i]<>ave then begin
a[i+1]:=a[i+1]+a[i]-ave;
a[i]:=ave;
inc(min);
end;
inc(i);
until i=n;
writeln(min);
end.
输入:
10
9 8 17 6 5 0 34 11 2 8 输出:8
|