結果

問題 No.300 平方数
ユーザー しらっ亭しらっ亭
提出日時 2015-11-13 22:24:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 539 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 11,008 KB
実行使用メモリ 8,792 KB
最終ジャッジ日時 2023-10-11 15:52:04
合計ジャッジ時間 3,320 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,604 KB
testcase_01 AC 19 ms
8,624 KB
testcase_02 AC 20 ms
8,584 KB
testcase_03 AC 19 ms
8,716 KB
testcase_04 AC 19 ms
8,640 KB
testcase_05 AC 19 ms
8,756 KB
testcase_06 AC 19 ms
8,688 KB
testcase_07 AC 19 ms
8,600 KB
testcase_08 AC 19 ms
8,680 KB
testcase_09 AC 19 ms
8,568 KB
testcase_10 AC 19 ms
8,580 KB
testcase_11 AC 19 ms
8,580 KB
testcase_12 AC 19 ms
8,696 KB
testcase_13 AC 137 ms
8,620 KB
testcase_14 AC 18 ms
8,628 KB
testcase_15 AC 19 ms
8,596 KB
testcase_16 AC 19 ms
8,620 KB
testcase_17 AC 18 ms
8,596 KB
testcase_18 AC 18 ms
8,584 KB
testcase_19 AC 18 ms
8,616 KB
testcase_20 AC 22 ms
8,624 KB
testcase_21 AC 19 ms
8,780 KB
testcase_22 AC 19 ms
8,792 KB
testcase_23 AC 29 ms
8,604 KB
testcase_24 AC 38 ms
8,756 KB
testcase_25 AC 114 ms
8,688 KB
testcase_26 AC 50 ms
8,728 KB
testcase_27 AC 39 ms
8,740 KB
testcase_28 AC 113 ms
8,608 KB
testcase_29 AC 95 ms
8,696 KB
testcase_30 AC 24 ms
8,680 KB
testcase_31 AC 26 ms
8,780 KB
testcase_32 AC 25 ms
8,572 KB
testcase_33 AC 59 ms
8,644 KB
testcase_34 AC 124 ms
8,620 KB
testcase_35 AC 87 ms
8,676 KB
testcase_36 AC 44 ms
8,552 KB
testcase_37 AC 46 ms
8,644 KB
testcase_38 AC 19 ms
8,584 KB
testcase_39 AC 20 ms
8,580 KB
testcase_40 AC 21 ms
8,612 KB
testcase_41 AC 40 ms
8,692 KB
testcase_42 AC 19 ms
8,572 KB
testcase_43 AC 20 ms
8,600 KB
testcase_44 AC 21 ms
8,624 KB
testcase_45 AC 20 ms
8,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
import math


def factorize(n):
    step = lambda x: 1 + (x << 2) - ((x >> 1) << 1)
    maxq = int(math.floor(math.sqrt(n)))
    d = 1
    q = n % 2 == 0 and 2 or 3
    while q <= maxq and n % q != 0:
        q = step(d)
        d += 1
    return q <= maxq and [q] + factorize(n // q) or [n]


def solve():
    X = int(input())
    fs = factorize(X)

    cs = Counter(fs)

    ans = 1
    for k in cs:
        if cs[k] % 2 == 1:
            ans *= k

    print(ans)


if __name__ == '__main__':
    solve()
0