解题思路:
注意事项:
参考代码:
N,M = map(int,input().split()) lights = [1] * N # 初始化列表 1为开,-1为关 closed = [] for i in range(1,M+1): for j in range(1,N+1): if j % i == 0: lights[j-1] = lights[j-1] * -1 #每次切换灯泡状态 for j in range(0,N): if lights[j] == -1: closed.append(j) print(','.join(str(i+1) for i in closed))
0.0分
0 人评分