結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー now4estnow4est
提出日時 2020-05-30 00:02:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 641 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 64,768 KB
最終ジャッジ日時 2024-04-24 02:42:24
合計ジャッジ時間 1,686 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
52,224 KB
testcase_01 AC 43 ms
51,712 KB
testcase_02 AC 42 ms
52,096 KB
testcase_03 AC 46 ms
57,728 KB
testcase_04 RE -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 49 ms
58,368 KB
testcase_08 AC 52 ms
58,112 KB
testcase_09 AC 45 ms
57,728 KB
testcase_10 AC 49 ms
57,856 KB
testcase_11 AC 47 ms
57,984 KB
testcase_12 AC 47 ms
57,856 KB
testcase_13 AC 47 ms
58,240 KB
testcase_14 AC 47 ms
57,984 KB
testcase_15 AC 45 ms
58,112 KB
testcase_16 AC 46 ms
58,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
# n = 10
# n = 536870912
n_org = n

def b(l):
    if len(l) == 0:
        return 1
    ans = 1
    for i in l:
        ans *= i[0] ** i[1]
    return ans

fac = []
i = 2
while True:
    if i * i > n_org:
        break

    if n % i == 0:
        ex = 0 # 指数
        while n % i == 0:
            ex += 1
            n /= i
        fac.append((i, ex))
    i += 1

if n != 1:
    fac.append((int(n), 1))

if fac[0][1] % 2 == 0:
    print(int(fac[0][0] ** (fac[0][1] / 2)), b(fac[1:]))
elif fac[0][1] >= 2:
    print(int(fac[0][0] ** (fac[0][1] // 2)), b([(fac[0][0], fac[0][1] % 2)] + fac[1:]))
else:
    print(1, b(fac))
0