def yuesefu(players,step,alive):
L = [i for i in range(1,players+1)]
a = 0
while len(L)>alive:
i = 0
while i<len(L):
a += 1
if a ==step:
L.remove(L[i])
a = 0
else:
i +=1
print(L)
return L
约瑟夫游戏2.0
最新推荐文章于 2024-04-28 21:41:57 发布
def yuesefu(players,step,alive):
L = [i for i in range(1,players+1)]
a = 0
while len(L)>alive:
i = 0
while i<len(L):
a += 1
if a ==step:
L.remove(L[i])
a = 0
else:
i +=1
print(L)
return L