結果

問題 No.278 連続する整数の和(2)
ユーザー roiti46roiti46
提出日時 2015-09-04 23:07:36
言語 PyPy2
(7.3.15)
結果
TLE  
実行時間 -
コード長 564 bytes
コンパイル時間 1,551 ms
コンパイル使用メモリ 77,632 KB
実行使用メモリ 84,396 KB
最終ジャッジ日時 2023-09-26 06:20:19
合計ジャッジ時間 6,426 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
78,336 KB
testcase_01 AC 84 ms
78,196 KB
testcase_02 AC 154 ms
80,100 KB
testcase_03 AC 83 ms
78,492 KB
testcase_04 AC 83 ms
78,064 KB
testcase_05 AC 86 ms
79,556 KB
testcase_06 AC 85 ms
79,416 KB
testcase_07 AC 84 ms
79,228 KB
testcase_08 AC 85 ms
79,280 KB
testcase_09 AC 84 ms
78,288 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