From 8116c88c2249147e50f866406e436793e0b24376 Mon Sep 17 00:00:00 2001 From: wwan13 Date: Tue, 21 May 2024 16:06:06 +0900 Subject: [PATCH] =?UTF-8?q?solve=20:=2017425=20=EC=95=BD=EC=88=98=EC=9D=98?= =?UTF-8?q?=20=ED=95=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/boj_17425.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 python/boj_17425.py diff --git a/python/boj_17425.py b/python/boj_17425.py new file mode 100644 index 0000000..6a20e10 --- /dev/null +++ b/python/boj_17425.py @@ -0,0 +1,28 @@ +import sys + +input = sys.stdin.readline + + +def solution(): + highest = 1000000 + dp = [0] * (highest + 1) + prefix_sum = [0] * (highest + 1) + + for i in range(1, highest + 1): + j = 1 + while i * j <= highest: + dp[i*j] += i + j += 1 + prefix_sum[i] = prefix_sum[i-1] + dp[i] + + t = int(input()) + for _ in range(t): + a = int(sys.stdin.readline()) + sys.stdout.write(str(prefix_sum[a]) + "\n") + + +def main(): + solution() + + +main() \ No newline at end of file