Skip to content

Commit

Permalink
solve : 17425 약수의 합
Browse files Browse the repository at this point in the history
  • Loading branch information
wwan13 committed May 21, 2024
1 parent 7dac536 commit 8116c88
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions python/boj_17425.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 8116c88

Please sign in to comment.