結果
問題 | No.1737 One to N |
ユーザー |
![]() |
提出日時 | 2021-11-14 20:03:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 100 ms / 2,000 ms |
コード長 | 1,576 bytes |
コンパイル時間 | 162 ms |
コンパイル使用メモリ | 82,152 KB |
実行使用メモリ | 80,268 KB |
最終ジャッジ日時 | 2024-11-30 04:00:56 |
合計ジャッジ時間 | 4,562 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#!/usr/bin/env python3from pprint import pprintfrom sys import setrecursionlimit, stdinfrom typing import Dict, Iterable, SetINF: int = 1 << 62MOD1000000007 = 10**9 + 7MOD998244353 = 998244353setrecursionlimit(1_000_000)def inputs(type_=int):ins = input().split()if isinstance(type_, Iterable):return [t(x) for t, x in zip(type_, ins)]else:return list(map(type_, ins))def input_(type_=int):a, = inputs(type_)return adef input1() -> int:return int(input())inputi = input1def input2():a, b = input().split()return int(a), int(b)def input3():a, b, c = input().split()return int(a), int(b), int(c)def input4():a, b, c, d = input().split()return int(a), int(b), int(c), int(d)def answer(res) -> None:print(res)exit()# start codingdef get_one_factor(n: int, start: int = 2) -> int:"""一つの素因数を計算する計算量は O(sqrt(n))"""i = startwhile i * i <= n:if n % i == 0:return ii += 1return ndef compute_factors(n: int):"""素因数分解を計算する計算量は O(sqrt(n)log(n))"""assert n >= 1if n == 1:return {}d = {}start = 2while n > 1:k = get_one_factor(n, start)start = kcount = 0while n % k == 0:n //= kcount += 1d[k] = countreturn dn = inputi()res = 0for f, cnt in compute_factors(n).items():res += f * cntprint(res)