题目是:
怎么ac,我的代码是:
from math import gcd
def count_red_to_blue(n, m, ops):
res = []
visited = [False] * (n + 1)
for op in ops:
cnt = 0
for i in range(0, n, gcd(n, op)):
if not visited[i]:
cnt += 1
visited[i] = True
res.append(cnt)
return res
# 读取输入数据
n, m = map(int, input().strip().split())
ops = list(map(int, input().strip().split()))
# 计算每轮操作中红色珍珠变为蓝色的数量
result = count_red_to_blue(n, m, ops)
# 输出结果
print(*result)