結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー zaki_chemtechzaki_chemtech
提出日時 2020-07-13 15:53:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 487 bytes
コンパイル時間 608 ms
コンパイル使用メモリ 87,076 KB
実行使用メモリ 76,828 KB
最終ジャッジ日時 2023-08-07 14:43:43
合計ジャッジ時間 3,185 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 95 ms
71,940 KB
testcase_01 AC 91 ms
71,736 KB
testcase_02 AC 90 ms
71,904 KB
testcase_03 AC 95 ms
76,588 KB
testcase_04 AC 91 ms
71,576 KB
testcase_05 AC 96 ms
76,552 KB
testcase_06 AC 96 ms
76,560 KB
testcase_07 AC 97 ms
76,504 KB
testcase_08 AC 95 ms
76,828 KB
testcase_09 AC 96 ms
76,564 KB
testcase_10 AC 96 ms
76,532 KB
testcase_11 AC 95 ms
76,536 KB
testcase_12 AC 97 ms
76,496 KB
testcase_13 AC 97 ms
76,676 KB
testcase_14 AC 96 ms
76,820 KB
testcase_15 AC 96 ms
76,504 KB
testcase_16 AC 95 ms
76,456 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime(p):
    memo = []
    for i in range(2,(int(p**0.5)+1)):
        while p%i==0:
            p //= i
            memo.append(i)
    if p != 1:
        memo.append(p)
    return memo

import collections

n=int(input())

memo = prime(n)

c = collections.Counter(memo)

score_sorted = sorted(c.items(), key=lambda x:-x[0])

ans_a = 1
ans_b = 1

for idx, val in score_sorted:
    if 0 < val//2:
        ans_a *= idx**(val//2)
    if val%2==1:
        ans_b *= idx
print(ans_a, ans_b)
0