Loading... ## 题目 ##  ## 思路 实在尴尬,一开始只会暴力循环,算半天算不出来,优化了但只优化一点点。最后用了网上大佬的思路,先找出n的因子,再枚举出积等于n的因式就可以了。。平均用时6.7s ## 题解 ```Python import math import time n = 2021041820210418 ans = 0 list = set() t1 = time.time() for i in range(1,int(math.sqrt(n)) + 1): if n % i == 0: list.add(i) list.add(n//i) for l in list: for w in list: for h in list: if l * w * h == n: ans += 1 t2 = time.time() print(ans) print(str(t2-t1)+"s") ``` 输出结果 ``` 2430 6.706071138381958s ``` Last modification:March 12, 2022 © Allow specification reprint Support Appreciate the author WeChat Like 0 如果觉得我的文章对你有用,请随意赞赏