結果
問題 |
No.278 連続する整数の和(2)
|
ユーザー |
|
提出日時 | 2015-09-04 23:06:55 |
言語 | Python2 (2.7.18) |
結果 |
TLE
|
実行時間 | - |
コード長 | 564 bytes |
コンパイル時間 | 627 ms |
コンパイル使用メモリ | 6,912 KB |
実行使用メモリ | 13,468 KB |
最終ジャッジ日時 | 2024-07-19 01:40:47 |
合計ジャッジ時間 | 5,112 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 TLE * 1 -- * 7 |
ソースコード
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