結果

問題 No.278 連続する整数の和(2)
ユーザー roiti46roiti46
提出日時 2015-09-04 23:06:55
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 564 bytes
コンパイル時間 76 ms
コンパイル使用メモリ 6,644 KB
実行使用メモリ 10,580 KB
最終ジャッジ日時 2023-09-26 06:20:05
合計ジャッジ時間 4,637 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 13 ms
10,580 KB
testcase_01 AC 13 ms
6,276 KB
testcase_02 AC 714 ms
6,276 KB
testcase_03 AC 13 ms
6,244 KB
testcase_04 AC 13 ms
6,344 KB
testcase_05 AC 14 ms
6,352 KB
testcase_06 AC 14 ms
6,340 KB
testcase_07 AC 15 ms
6,240 KB
testcase_08 AC 14 ms
6,344 KB
testcase_09 AC 14 ms
6,284 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(raw_input())

n = N
i = 2
num1, num2 = defaultdict(int), defaultdict(int)
while i*i <= n:
    cnt = 0
    while n % i == 0:
        n /= i
        cnt += 1
    if cnt > 0:
        num1[i] = cnt
    i += 1
if n > 1:
    num1[n] = 1

n = N*(N + 1)/2
i = 2
while i*i <= n:
    cnt = 0
    while n % i == 0:
        n /= i
        cnt += 1
    if cnt > 0:
        num2[i] = cnt
    i += 1
if n > 1:
    num2[n] = 1

ans = 1
for a, p in num1.items():
    p = min(p, num2[a])
    ans *= (a ** (p + 1) - 1) / (a - 1)
print ans
0