結果

問題 No.1737 One to N
ユーザー yassu0320yassu0320
提出日時 2021-11-14 20:03:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,576 bytes
コンパイル時間 264 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 79,140 KB
最終ジャッジ日時 2023-08-20 03:59:45
合計ジャッジ時間 7,101 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
78,840 KB
testcase_01 AC 169 ms
79,052 KB
testcase_02 AC 165 ms
78,888 KB
testcase_03 AC 162 ms
79,008 KB
testcase_04 AC 160 ms
79,000 KB
testcase_05 AC 161 ms
79,080 KB
testcase_06 AC 165 ms
79,024 KB
testcase_07 AC 163 ms
79,128 KB
testcase_08 AC 162 ms
79,060 KB
testcase_09 AC 163 ms
79,044 KB
testcase_10 AC 160 ms
78,976 KB
testcase_11 AC 162 ms
78,940 KB
testcase_12 AC 162 ms
79,072 KB
testcase_13 AC 160 ms
79,084 KB
testcase_14 AC 160 ms
79,064 KB
testcase_15 AC 163 ms
78,792 KB
testcase_16 AC 162 ms
79,056 KB
testcase_17 AC 163 ms
78,980 KB
testcase_18 AC 162 ms
78,984 KB
testcase_19 AC 161 ms
79,008 KB
testcase_20 AC 164 ms
78,892 KB
testcase_21 AC 163 ms
78,920 KB
testcase_22 AC 161 ms
78,980 KB
testcase_23 AC 163 ms
79,084 KB
testcase_24 AC 162 ms
79,140 KB
testcase_25 AC 164 ms
78,948 KB
testcase_26 AC 167 ms
78,940 KB
testcase_27 AC 162 ms
79,008 KB
testcase_28 AC 164 ms
79,132 KB
testcase_29 AC 160 ms
78,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3

from pprint import pprint
from sys import setrecursionlimit, stdin
from typing import Dict, Iterable, Set

INF: int = 1 << 62
MOD1000000007 = 10**9 + 7
MOD998244353 = 998244353
setrecursionlimit(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 a


def input1() -> int:
    return int(input())
inputi = input1


def 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 coding

def get_one_factor(n: int, start: int = 2) -> int:
    """
    一つの素因数を計算する
    計算量は O(sqrt(n))
    """
    i = start
    while i * i <= n:
        if n % i == 0:
            return i
        i += 1

    return n


def compute_factors(n: int):
    """
    素因数分解を計算する
    計算量は O(sqrt(n)log(n))
    """
    assert n >= 1

    if n == 1:
        return {}

    d = {}
    start = 2
    while n > 1:
        k = get_one_factor(n, start)
        start = k
        count = 0
        while n % k == 0:
            n //= k
            count += 1

        d[k] = count

    return d

n = inputi()
res = 0
for f, cnt in compute_factors(n).items():
    res += f * cnt

print(res)
0