AcWing 871. 约数之和python3
原题链接
简单
作者:
xanxus1111
,
2020-06-03 16:15:38
,
所有人可见
,
阅读 417
if __name__=='__main__':
mod = int(1e9+7)
n = int(input())
primes = {}
for i in range(n):
x = int(input())
#分解质因数
i = 2
while i <= x/i:
while x % i == 0:
x //= i #也可以写成 x = int(x / i) python的bug 但不能直接写成 x/=i
if i in primes: #检查字典中是否存过
primes[i] += 1
else:
primes[i] = 1
i+=1
if x > 1 :
if x in primes: #检查字典中是否存过
primes[x] += 1
else:
primes[x] = 1
res = 1
for p in primes:
t = 1
for i in range(primes[p]):
t = (t * p + 1)
res = res * t
print(int(res% mod))