NC25046. [USACO 2007 Jan L]Factors
描述
输入描述
Line 1: A single integer, N
输出描述
Line 1: A single integer that is the sum of the factors of N (not including N itself)
示例1
输入:
314
输出:
160
Python3 解法, 执行用时: 42ms, 内存消耗: 4572K, 提交时间: 2023-08-16 09:21:41
N = int(input()) # 分解质因数 def getFactors(n): r = {1} for k in range(2, int(n ** 0.5) + 1): if n % k == 0: r.add(k) r.add(n // k) return r s = sum(getFactors(N)) print(s)