From 3cf4d9b2ccc398202de56e6b2ba5dd052bc3376e Mon Sep 17 00:00:00 2001 From: hidehic0 Date: Fri, 31 Jan 2025 18:06:29 +0900 Subject: [PATCH] =?UTF-8?q?heapq=E3=82=92=E4=BD=BF=E3=81=A3=E3=81=A6?= =?UTF-8?q?=E3=81=84=E3=81=9F=E3=81=AE=E3=81=A7=E3=80=81=E3=82=BD=E3=83=BC?= =?UTF-8?q?=E3=83=88=E3=81=95=E3=82=8C=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B?= =?UTF-8?q?=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/math_func.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/math_func.py b/libs/math_func.py index c1670a6..c59611e 100644 --- a/libs/math_func.py +++ b/libs/math_func.py @@ -69,8 +69,6 @@ def calc_divisors(N): 計算量は、√Nです 約数は昇順に並んでいます """ - import heapq - result = [] for i in range(1, N + 1): @@ -80,11 +78,11 @@ def calc_divisors(N): if N % i != 0: continue - heapq.heappush(result, i) + result.append(i) if N // i != i: - heapq.heappush(result, N // i) + result.append(N // i) - return result + return sorted(result) def factorization(n):