結果
問題 | No.278 連続する整数の和(2) |
ユーザー |
![]() |
提出日時 | 2020-01-31 20:48:11 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 134 ms / 2,000 ms |
コード長 | 1,531 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-09-17 06:59:07 |
合計ジャッジ時間 | 1,621 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 18 |
ソースコード
import syssys.setrecursionlimit(10 ** 6)from bisect import *from collections import *from heapq import *int1 = lambda x: int(x) - 1p2D = lambda x: print(*x, sep="\n")def II(): return int(sys.stdin.readline())def SI(): return sys.stdin.readline()[:-1]def MI(): return map(int, sys.stdin.readline().split())def MI1(): return map(int1, sys.stdin.readline().split())def MF(): return map(float, sys.stdin.readline().split())def LI(): return list(map(int, sys.stdin.readline().split()))def LI1(): return list(map(int1, sys.stdin.readline().split()))def LF(): return list(map(float, sys.stdin.readline().split()))def LLI(rows_number): return [LI() for _ in range(rows_number)]dij = [(0, 1), (1, 0), (0, -1), (-1, 0)]# (底,指数)を返す# 18=2**1 * 3**2なので[(2,1),(3,2)]def PrimeFactorization(x):def plist(x):if x < 2: return []if x & 1 == 0: return [2] + plist(x // 2)for p in range(3, x + 1, 2):if x % p == 0: return [p] + plist(x // p)if p ** 2 > x: return [x]pl = plist(x)pp, ee = [], []for p in pl:if not pp or p != pp[-1]:pp += [p]ee += [0]ee[-1] += 1return [(p, e) for p, e in zip(pp, ee)]def gcd(a, b):while b: a, b = b, a % breturn adef expsum(p, e):return (pow(p, e + 1) - 1) // (p - 1)def main():n = II()c = (n - 1) * n // 2g = gcd(n, c)ans = 1for p, e in PrimeFactorization(g):ans *= expsum(p, e)print(ans)main()