結果

問題 No.300 平方数
ユーザー Meso Meso
提出日時 2024-11-03 18:51:13
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 492 bytes
コンパイル時間 495 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-11-03 18:51:17
合計ジャッジ時間 4,290 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

def is_prime(n):
    ans = [1]
    
    while n % 2 == 0:
        ans.append(2)
        n //=2
        
    f = 3
    while f * f <= n:
        if n % f == 0:
            ans.append(f)
            n //= f
        else:
            f += 2
            
    if n != 1:
        ans.append(n)

    return ans

x = int(input())

c = collections.Counter(is_prime(x))
C = sorted(c.items(), key=lambda x:x[0])

ans = 1
for k, v in C:
    if v % 2 == 1:
        ans *= k

print(ans)
0