結果

問題 No.300 平方数
コンテスト
ユーザー zombietan
提出日時 2016-06-08 20:25:44
言語 Python3
(3.14.3 + numpy 2.4.4 + scipy 1.17.1)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 461 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 354 ms
コンパイル使用メモリ 20,696 KB
実行使用メモリ 15,360 KB
最終ジャッジ日時 2026-04-25 06:15:05
合計ジャッジ時間 6,678 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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