結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー now4est
提出日時 2020-05-30 00:02:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 641 bytes
コンパイル時間 195 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 65,868 KB
最終ジャッジ日時 2024-11-06 09:27:56
合計ジャッジ時間 1,687 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 11 WA * 2 RE * 1
権限があれば一括ダウンロードができます

ソースコード

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