結果

問題 No.278 連続する整数の和(2)
ユーザー しらっ亭
提出日時 2015-09-05 22:00:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 429 bytes
コンパイル時間 77 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 20,816 KB
最終ジャッジ日時 2024-12-23 09:04:57
合計ジャッジ時間 2,479 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

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