結果

問題 No.278 連続する整数の和(2)
ユーザー H3PO4H3PO4
提出日時 2020-06-10 08:35:22
言語 Python3
(3.10.1 + numpy 1.22.3 + scipy 1.8.0)
結果
AC  
実行時間 144 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 132 ms
使用メモリ 8,148 KB
最終ジャッジ日時 2023-01-19 11:14:07
合計ジャッジ時間 2,655 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 16 ms
8,072 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 144 ms
8,028 KB
testcase_03 AC 16 ms
8,100 KB
testcase_04 AC 16 ms
7,932 KB
testcase_05 AC 17 ms
8,032 KB
testcase_06 AC 18 ms
8,032 KB
testcase_07 AC 18 ms
7,916 KB
testcase_08 AC 77 ms
7,992 KB
testcase_09 AC 78 ms
8,036 KB
testcase_10 AC 110 ms
8,040 KB
testcase_11 AC 90 ms
7,936 KB
testcase_12 AC 16 ms
7,724 KB
testcase_13 AC 109 ms
8,148 KB
testcase_14 AC 92 ms
7,988 KB
testcase_15 AC 101 ms
8,044 KB
testcase_16 AC 82 ms
8,044 KB
testcase_17 AC 140 ms
8,032 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