题目:输入n个整数,依次输出每个数的约数的个数(运行时间1500ms)

import os
def count(x):
    factor = 2
    num = 1
    while (factor * factor <= x):
        count = 1
        while (x % factor == 0):
            count += 1
            x /= factor
        num *= count
        factor += 1
    return (num * (1 + (x > 1)))

try:
    n = int(input())  # 行数
    if(n!=0):
        #if(n>0 and n<=1000):
        s = list(map(int, input().split()))
        #print(s)
    else:
        os._exit(0)
    for item in s:
        it=count(item)
        print(it)
except:
        pass
View Code

相关文章: