結果

問題 No.278 連続する整数の和(2)
ユーザー H3PO4H3PO4
提出日時 2020-06-10 08:35:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 98 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 8,088 KB
最終ジャッジ日時 2023-09-03 20:04:39
合計ジャッジ時間 2,079 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,872 KB
testcase_01 AC 16 ms
7,888 KB
testcase_02 AC 98 ms
7,992 KB
testcase_03 AC 14 ms
8,068 KB
testcase_04 AC 14 ms
7,948 KB
testcase_05 AC 15 ms
7,936 KB
testcase_06 AC 16 ms
8,080 KB
testcase_07 AC 15 ms
7,924 KB
testcase_08 AC 62 ms
7,884 KB
testcase_09 AC 65 ms
7,960 KB
testcase_10 AC 89 ms
7,928 KB
testcase_11 AC 68 ms
7,888 KB
testcase_12 AC 14 ms
7,924 KB
testcase_13 AC 73 ms
8,088 KB
testcase_14 AC 61 ms
7,936 KB
testcase_15 AC 66 ms
7,876 KB
testcase_16 AC 57 ms
7,928 KB
testcase_17 AC 93 ms
7,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd


def factorization(n):
    arr = dict()
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt

    if temp != 1:
        arr[temp] = 1

    if not arr and n != 1:
        arr[n] = 1

    return arr


N = int(input())

M = gcd(N, N * (N + 1) // 2)
ans = 1
for k, v in factorization(M).items():
    ans *= (k ** (v + 1) - 1) // (k - 1)
print(ans)
0