結果

問題 No.278 連続する整数の和(2)
ユーザー しらっ亭しらっ亭
提出日時 2015-09-05 22:00:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 10,768 KB
実行使用メモリ 18,232 KB
最終ジャッジ日時 2023-08-24 22:41:34
合計ジャッジ時間 2,404 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,704 KB
testcase_01 AC 15 ms
7,784 KB
testcase_02 AC 155 ms
16,680 KB
testcase_03 AC 15 ms
7,792 KB
testcase_04 AC 15 ms
7,840 KB
testcase_05 AC 17 ms
8,428 KB
testcase_06 AC 18 ms
8,460 KB
testcase_07 AC 19 ms
8,560 KB
testcase_08 AC 135 ms
15,908 KB
testcase_09 AC 134 ms
15,920 KB
testcase_10 AC 169 ms
18,232 KB
testcase_11 AC 139 ms
15,704 KB
testcase_12 AC 15 ms
7,916 KB
testcase_13 AC 122 ms
14,636 KB
testcase_14 AC 99 ms
13,456 KB
testcase_15 AC 108 ms
13,872 KB
testcase_16 AC 88 ms
12,532 KB
testcase_17 AC 138 ms
16,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def divisors(n):
    rt = int(n ** 0.5) + 1
    s = [False] * rt
    s[1] = True
    for x in range(2, rt):
        if n % x == 0:
            s[x] = True
    return (i for i in range(rt) if s[i])


def solve():
    N = int(input())

    g = N if N % 2 else N // 2

    s = 0
    for d in divisors(g):
        s += d
        e = g // d
        if e != d:
            s += e

    print(s)


if __name__ == '__main__':
    solve()
0