結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー lloyzlloyz
提出日時 2022-02-23 00:14:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,696 KB
実行使用メモリ 8,624 KB
最終ジャッジ日時 2023-09-13 15:04:58
合計ジャッジ時間 1,248 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,592 KB
testcase_01 AC 20 ms
8,448 KB
testcase_02 AC 19 ms
8,480 KB
testcase_03 AC 19 ms
8,596 KB
testcase_04 AC 18 ms
8,460 KB
testcase_05 AC 18 ms
8,508 KB
testcase_06 AC 19 ms
8,464 KB
testcase_07 AC 19 ms
8,460 KB
testcase_08 AC 18 ms
8,576 KB
testcase_09 AC 20 ms
8,620 KB
testcase_10 AC 19 ms
8,444 KB
testcase_11 AC 18 ms
8,500 KB
testcase_12 AC 19 ms
8,544 KB
testcase_13 AC 19 ms
8,448 KB
testcase_14 AC 19 ms
8,624 KB
testcase_15 AC 19 ms
8,452 KB
testcase_16 AC 18 ms
8,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

n = int(input())

Prime_cnt = defaultdict(int)
while n % 2 == 0:
    Prime_cnt[2] += 1
    n //= 2

f = 3
while f * f <= n:
    while n % f == 0:
        Prime_cnt[f] += 1
        n //= f
    f += 2
if n != 1:
    Prime_cnt[n] += 1

a, b = 1, 1
for prime, cnt in Prime_cnt.items():
    q, r = divmod(cnt, 2)
    a *= pow(prime, q)
    b *= pow(prime, r)
print(a, b)
0