1.约瑟夫环问题
lis = [ i for i in range(1,101)] print(lis) m = 5 while len(lis) >= m: lis.remove(lis[m-1]) lis = lis[m-1:]+lis[0:m-1] while len(lis) > 1: n = len(lis) print(n) print(lis) if n < m: ind = m // n + 1 # print(lis) lis = lis*ind + lis print(lis) # print(len(lis)) # print(m-1) lis.remove(lis[m-1]) lis = lis[m-1:m+n-2] print(lis)