import random
def divide(total = 10000, person = 10, n = 100000):
get = [0 for i in range(person)]
for j in range(n):
amount = total
for i in range(0, person-1):
x = 2 * amount // (person - i)
a = random.randint(1, x)
get[i] += a
amount -= a
get[person-1] += amount
return [i//n for i in get]
print(1, divide(n=1))
print(2, divide(n=1))
print('First 100,000 times simulation:',divide())
print('Second 100,000 times simulation:',divide())
# 输出:
# (1, [205, 593, 974, 69, 561, 696, 2725, 2736, 581, 860])
# (2, [157, 766, 894, 280, 1008, 2585, 1453, 90, 2353, 414])
# ('First 100,000 times simulation:', [998, 998, 1002, 1000, 1002, 1003, 998, 998, 999, 998])
# ('Second 100,000 times simulation:', [997, 1002, 1004, 997, 1000, 999, 997, 998, 1003, 998])
# 可见单独一次来看,每个人抽到的金额差别比较大;但总体来看,先抽后抽没有差别。