結果

問題 No.300 平方数
ユーザー ThetaTheta
提出日時 2022-10-24 14:47:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 740 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-09-15 14:29:19
合計ジャッジ時間 4,953 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,180 KB
testcase_01 AC 16 ms
8,196 KB
testcase_02 AC 17 ms
8,148 KB
testcase_03 RE -
testcase_04 AC 15 ms
8,220 KB
testcase_05 AC 16 ms
8,156 KB
testcase_06 AC 16 ms
8,148 KB
testcase_07 AC 16 ms
8,268 KB
testcase_08 AC 16 ms
8,264 KB
testcase_09 AC 16 ms
8,144 KB
testcase_10 AC 15 ms
8,140 KB
testcase_11 AC 15 ms
8,148 KB
testcase_12 AC 16 ms
8,108 KB
testcase_13 AC 165 ms
8,268 KB
testcase_14 AC 15 ms
8,188 KB
testcase_15 AC 16 ms
8,204 KB
testcase_16 AC 16 ms
8,108 KB
testcase_17 AC 15 ms
8,180 KB
testcase_18 AC 15 ms
8,252 KB
testcase_19 AC 15 ms
8,144 KB
testcase_20 AC 19 ms
8,180 KB
testcase_21 AC 15 ms
8,108 KB
testcase_22 AC 16 ms
8,196 KB
testcase_23 AC 27 ms
8,268 KB
testcase_24 AC 39 ms
8,292 KB
testcase_25 AC 133 ms
8,144 KB
testcase_26 AC 54 ms
8,328 KB
testcase_27 AC 41 ms
8,204 KB
testcase_28 AC 134 ms
8,288 KB
testcase_29 AC 111 ms
8,320 KB
testcase_30 AC 23 ms
8,148 KB
testcase_31 AC 25 ms
8,260 KB
testcase_32 AC 24 ms
8,268 KB
testcase_33 AC 65 ms
8,108 KB
testcase_34 AC 147 ms
8,288 KB
testcase_35 AC 101 ms
8,136 KB
testcase_36 AC 48 ms
8,180 KB
testcase_37 AC 49 ms
8,192 KB
testcase_38 AC 16 ms
8,204 KB
testcase_39 AC 17 ms
8,104 KB
testcase_40 AC 17 ms
8,148 KB
testcase_41 AC 41 ms
8,148 KB
testcase_42 AC 16 ms
8,292 KB
testcase_43 AC 17 ms
8,260 KB
testcase_44 AC 17 ms
8,148 KB
testcase_45 AC 16 ms
8,264 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())
    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