pythondef precompute(AS) maxAS = max(AS) eratree = [0] * (maxAS + 10) for p in range(2, maxAS + 1): if eratree[p]: continue # p is prime eratree[p] = p x = p * p while x <= maxAS: if not eratree[x]: eratree[x] = p x += p return eratree
x = p * p
pythonfor a in AS: factors = [] while a > 1: d = eratree[a] factors.append(d) a //= d ...