結果

問題 No.300 平方数
ユーザー ThetaTheta
提出日時 2022-10-24 14:48:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 164 ms / 1,000 ms
コード長 788 bytes
コンパイル時間 187 ms
コンパイル使用メモリ 10,988 KB
実行使用メモリ 8,324 KB
最終ジャッジ日時 2023-09-15 14:30:02
合計ジャッジ時間 3,549 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
8,124 KB
testcase_01 AC 15 ms
8,132 KB
testcase_02 AC 16 ms
8,248 KB
testcase_03 AC 15 ms
8,292 KB
testcase_04 AC 15 ms
8,272 KB
testcase_05 AC 16 ms
8,132 KB
testcase_06 AC 16 ms
8,128 KB
testcase_07 AC 16 ms
8,308 KB
testcase_08 AC 15 ms
8,048 KB
testcase_09 AC 15 ms
8,212 KB
testcase_10 AC 15 ms
8,268 KB
testcase_11 AC 16 ms
8,116 KB
testcase_12 AC 15 ms
8,200 KB
testcase_13 AC 164 ms
8,252 KB
testcase_14 AC 15 ms
8,132 KB
testcase_15 AC 16 ms
8,216 KB
testcase_16 AC 15 ms
8,052 KB
testcase_17 AC 15 ms
8,148 KB
testcase_18 AC 16 ms
8,204 KB
testcase_19 AC 15 ms
8,272 KB
testcase_20 AC 20 ms
8,212 KB
testcase_21 AC 15 ms
8,212 KB
testcase_22 AC 16 ms
8,108 KB
testcase_23 AC 29 ms
8,156 KB
testcase_24 AC 40 ms
8,200 KB
testcase_25 AC 136 ms
8,204 KB
testcase_26 AC 54 ms
8,216 KB
testcase_27 AC 41 ms
8,132 KB
testcase_28 AC 133 ms
8,268 KB
testcase_29 AC 111 ms
8,124 KB
testcase_30 AC 23 ms
8,212 KB
testcase_31 AC 25 ms
8,152 KB
testcase_32 AC 24 ms
8,200 KB
testcase_33 AC 65 ms
8,208 KB
testcase_34 AC 145 ms
8,168 KB
testcase_35 AC 102 ms
8,320 KB
testcase_36 AC 48 ms
8,296 KB
testcase_37 AC 50 ms
8,200 KB
testcase_38 AC 16 ms
8,152 KB
testcase_39 AC 18 ms
8,052 KB
testcase_40 AC 17 ms
8,216 KB
testcase_41 AC 42 ms
8,288 KB
testcase_42 AC 16 ms
8,204 KB
testcase_43 AC 17 ms
8,212 KB
testcase_44 AC 18 ms
8,324 KB
testcase_45 AC 17 ms
8,212 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():
    X = int(input())
    if X == 1:
        print(1)
        return 
    divisors = calc_positive_divisors(X)

    Y = 1
    for divisor, count_ in divisors.items():
        if count_ % 2 == 1:
            Y *= divisor
    print(Y)


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