python 第二和第五1.2s超时,有没有大佬帮帮 QQ182978289
查看原帖
python 第二和第五1.2s超时,有没有大佬帮帮 QQ182978289
460444
玲珑安入骨楼主2021/12/13 19:47
num = int(input())
num_list = num * [1] + num*[0]

copy_list = num_list[:]
counts = num
id = 0

while True:
    for _ in range(num):
        step = (counts+id-1) % (len(copy_list))
        if copy_list[step] == 0:
            del copy_list[step]
            id = step

        else:
            counts += 1
            id = 0
            copy_list = num_list[:]
            break
    else:
        print(counts)
        break
2021/12/13 19:47
加载中...