結果

問題 No.888 約数の総和
ユーザー Theta
提出日時 2022-11-25 14:00:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 555 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 82,300 KB
実行使用メモリ 60,784 KB
最終ジャッジ日時 2024-10-01 22:09:51
合計ジャッジ時間 2,734 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import sqrt, floor


def calc_positive_divisors(num: int) -> list[int]:
    small_divisors = []
    large_divisors = []
    for n in range(1, floor(sqrt(num))+1):
        if num % n == 0:
            small_divisors.append(n)
            large_divisors.append(num//n)
    if small_divisors[-1] == large_divisors[-1]:
        large_divisors.pop()
    divisors = small_divisors + list(reversed(large_divisors))
    return divisors


def main():
    N = int(input())
    print(sum(calc_positive_divisors(N)))


if __name__ == "__main__":
    main()
0