結果

問題 No.278 連続する整数の和(2)
ユーザー matsu7874matsu7874
提出日時 2015-10-21 15:51:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 248 ms / 2,000 ms
コード長 463 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 10,676 KB
実行使用メモリ 8,436 KB
最終ジャッジ日時 2023-08-24 22:44:02
合計ジャッジ時間 2,658 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,328 KB
testcase_01 AC 15 ms
7,828 KB
testcase_02 AC 103 ms
8,260 KB
testcase_03 AC 16 ms
8,396 KB
testcase_04 AC 16 ms
7,836 KB
testcase_05 AC 19 ms
7,800 KB
testcase_06 AC 17 ms
8,264 KB
testcase_07 AC 23 ms
7,844 KB
testcase_08 AC 248 ms
7,852 KB
testcase_09 AC 98 ms
8,436 KB
testcase_10 AC 121 ms
8,272 KB
testcase_11 AC 240 ms
7,940 KB
testcase_12 AC 15 ms
8,172 KB
testcase_13 AC 205 ms
7,844 KB
testcase_14 AC 69 ms
8,344 KB
testcase_15 AC 180 ms
7,804 KB
testcase_16 AC 144 ms
7,788 KB
testcase_17 AC 100 ms
8,432 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def get_divisors(n):
    # 約数列挙
    divisors = set()
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.add(i)
            divisors.add(n // i)
    list(divisors)
    return divisors

n = int(input())
if n % 2 == 1:
    print(sum(get_divisors(n)))
    exit()
divisors = [get_divisors(n), get_divisors(n - 1)]
total = 0
for d in divisors[0]:
    if d * 2 in divisors[0] or d in divisors[1]:
        total += d
print(total)
0