function distribute=distribute(people,seat)
%people矩阵:(n,1)n个单位人数
%seat:总席位减n
useseat=ones(length(people),1);
freeseat=seat;
Q=@(people,useseat) people.^2./((useseat+1).*useseat);
while freeseat>0
A=Q(people,useseat);
j=find(A==max(A));
if length(j)~=1
useseat(j(1))=useseat(j(1))+1;
else
useseat(j)=useseat(j)+1;
freeseat=freeseat-1;
end
end
distribute=[people,useseat];
end
有问题或想讨论可联系Q:1544651300