結果

問題 No.278 連続する整数の和(2)
ユーザー ckawatakckawatak
提出日時 2018-03-12 22:11:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 805 bytes
コンパイル時間 1,110 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 59,776 KB
最終ジャッジ日時 2024-04-26 22:19:31
合計ジャッジ時間 1,835 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,096 KB
testcase_01 AC 39 ms
52,352 KB
testcase_02 AC 54 ms
58,496 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 38 ms
52,096 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 38 ms
51,584 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())

def factorize(n):
    
    def divisibility(n, m):
        c = 0
        while n % m == 0:
            c += 1
            n /= m
        return c, n

    divisors = []
    c, m = divisibility(n, 2)
    if 0 < c:
        divisors.append((2, c))
    c, m = divisibility(m, 3)
    if 0 < c:
        divisors.append((3, c))
    x = 5
    while x * x <= m:
        c, m = divisibility(m, x)
        if c > 0:
            divisors.append((x, c))
        if x % 6 == 5:
            x += 2
        else:
            x += 4
    if 1 < m:
        divisors.append((m, 1))
    return divisors

def sum_divisors(p, n):
    a = 0
    while n > 0:
        a += p ** n
        n -= 1
    return a + 1

if N % 2 == 0:
    N /= 2

a = 1
for p, q in factorize(N):
    a *= sum_divisors(p, q)

print(a)    
0