結果

問題 No.312 置換処理
ユーザー ThetaTheta
提出日時 2022-10-24 15:08:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 778 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 10,776 KB
実行使用メモリ 8,304 KB
最終ジャッジ日時 2023-09-15 14:47:49
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,244 KB
testcase_01 AC 87 ms
8,132 KB
testcase_02 AC 168 ms
8,148 KB
testcase_03 AC 120 ms
8,124 KB
testcase_04 AC 15 ms
8,204 KB
testcase_05 AC 17 ms
8,248 KB
testcase_06 AC 23 ms
8,156 KB
testcase_07 AC 56 ms
8,244 KB
testcase_08 AC 21 ms
8,156 KB
testcase_09 AC 24 ms
8,200 KB
testcase_10 AC 15 ms
8,024 KB
testcase_11 AC 28 ms
8,116 KB
testcase_12 AC 15 ms
8,212 KB
testcase_13 AC 15 ms
8,240 KB
testcase_14 AC 15 ms
8,120 KB
testcase_15 AC 21 ms
8,116 KB
testcase_16 AC 16 ms
8,124 KB
testcase_17 AC 27 ms
8,248 KB
testcase_18 AC 16 ms
8,208 KB
testcase_19 AC 14 ms
8,200 KB
testcase_20 AC 21 ms
8,160 KB
testcase_21 AC 15 ms
8,148 KB
testcase_22 AC 15 ms
8,296 KB
testcase_23 AC 15 ms
8,112 KB
testcase_24 AC 15 ms
8,152 KB
testcase_25 AC 15 ms
8,160 KB
testcase_26 AC 14 ms
8,156 KB
testcase_27 AC 15 ms
8,128 KB
testcase_28 AC 14 ms
8,156 KB
testcase_29 AC 15 ms
8,116 KB
testcase_30 AC 29 ms
8,292 KB
testcase_31 AC 28 ms
8,304 KB
testcase_32 AC 29 ms
8,100 KB
testcase_33 AC 60 ms
8,024 KB
testcase_34 AC 62 ms
8,024 KB
testcase_35 AC 19 ms
8,132 KB
testcase_36 AC 15 ms
8,208 KB
testcase_37 AC 15 ms
8,032 KB
testcase_38 AC 15 ms
8,112 KB
testcase_39 AC 15 ms
8,208 KB
testcase_40 AC 15 ms
8,104 KB
testcase_41 AC 15 ms
8,124 KB
testcase_42 AC 15 ms
8,112 KB
testcase_43 AC 15 ms
8,116 KB
testcase_44 AC 15 ms
8,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import count


def calc_positive_divisors(num: int) -> dict[int, int]:
    if num < 2:
        raise ValueError

    divisors = {}
    for divisor in count(2):
        if divisor ** 2 > num:
            if num != 1:
                divisors[num] = 1
            break
        while num % divisor == 0 and num != 1:
            try:
                divisors[divisor] += 1
            except KeyError:
                divisors[divisor] = 1
            num //= divisor

    return divisors


def main():
    N = int(input())
    divisors = calc_positive_divisors(N)
    try:
        divisor_2 = divisors.pop(2)
        if divisor_2 >= 2:
            divisors[4] = 1
    except KeyError:
        pass

    print(min(divisors))


if __name__ == "__main__":
    main()
0