結果

問題 No.300 平方数
ユーザー zombietanzombietan
提出日時 2016-06-08 20:25:44
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 119 ms / 1,000 ms
コード長 461 bytes
コンパイル時間 237 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-10-09 03:21:00
合計ジャッジ時間 3,471 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import reduce
from collections import Counter
N = int(input())

def factors(x):
    f = [1]
    while x % 2 == 0:
        f.append(2)
        x = x // 2
    n=3
    while x >= n * n:
        while x % n == 0:
            f.append(n)
            x = x // n
        n = n + 2
    if x == 1:
        return f
    f.append(x)
    return f

cnt = Counter(factors(N))
ans = reduce(lambda x, y: x * y, [i for i, v in cnt.items() if v%2 != 0])
print(ans)
0