分糖果
n = int(4)
s = int(16)#当前拥有的糖果
f = 1 #f是需要给个人的糖果
res = [0]*n
def ss(n,s,f,res):
for i in range(n):
if s >= f:#满足需求
res[i] = res[i] + f
s = s - f
else:#不满足需求,给出剩余全部
res[i] = res[i] + s
s = s - s
f = f+1
if s>0:
ss(n,s,f,res)
else:
print(res)
ss(n,s,f,res)