結果

問題 No.300 平方数
ユーザー rpy3cpprpy3cpp
提出日時 2015-11-13 22:24:18
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 139 ms / 1,000 ms
コード長 667 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 8,772 KB
最終ジャッジ日時 2023-10-11 15:51:53
合計ジャッジ時間 3,885 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,588 KB
testcase_01 AC 19 ms
8,656 KB
testcase_02 AC 20 ms
8,548 KB
testcase_03 AC 19 ms
8,624 KB
testcase_04 AC 19 ms
8,496 KB
testcase_05 AC 19 ms
8,656 KB
testcase_06 AC 19 ms
8,616 KB
testcase_07 AC 19 ms
8,560 KB
testcase_08 AC 20 ms
8,616 KB
testcase_09 AC 19 ms
8,532 KB
testcase_10 AC 19 ms
8,492 KB
testcase_11 AC 20 ms
8,724 KB
testcase_12 AC 19 ms
8,664 KB
testcase_13 AC 139 ms
8,712 KB
testcase_14 AC 19 ms
8,568 KB
testcase_15 AC 20 ms
8,660 KB
testcase_16 AC 19 ms
8,500 KB
testcase_17 AC 20 ms
8,564 KB
testcase_18 AC 20 ms
8,632 KB
testcase_19 AC 19 ms
8,688 KB
testcase_20 AC 23 ms
8,716 KB
testcase_21 AC 19 ms
8,692 KB
testcase_22 AC 19 ms
8,504 KB
testcase_23 AC 30 ms
8,592 KB
testcase_24 AC 40 ms
8,732 KB
testcase_25 AC 115 ms
8,764 KB
testcase_26 AC 55 ms
8,548 KB
testcase_27 AC 40 ms
8,624 KB
testcase_28 AC 113 ms
8,564 KB
testcase_29 AC 95 ms
8,708 KB
testcase_30 AC 25 ms
8,504 KB
testcase_31 AC 27 ms
8,692 KB
testcase_32 AC 26 ms
8,772 KB
testcase_33 AC 58 ms
8,624 KB
testcase_34 AC 124 ms
8,528 KB
testcase_35 AC 88 ms
8,492 KB
testcase_36 AC 45 ms
8,656 KB
testcase_37 AC 46 ms
8,628 KB
testcase_38 AC 19 ms
8,592 KB
testcase_39 AC 20 ms
8,568 KB
testcase_40 AC 20 ms
8,560 KB
testcase_41 AC 40 ms
8,596 KB
testcase_42 AC 19 ms
8,592 KB
testcase_43 AC 20 ms
8,544 KB
testcase_44 AC 21 ms
8,632 KB
testcase_45 AC 20 ms
8,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import collections

def factorize(n):
    ''' returns a list of prime factors of n.
    ex. factorize(24) = [2, 2, 2, 3]
    source: Rossetta code: prime factorization (slightly modified)
    http://rosettacode.org/wiki/Prime_decomposition#Python:_Using_floating_point
    '''
    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]

X = int(input())
fac = collections.Counter(factorize(X))
Y = 1
for p, k in fac.items():
    if k & 1:
        Y *= p
print(Y)
0