結果

問題 No.1063 ルートの計算 / Sqrt Calculation
コンテスト
ユーザー r_ishida
提出日時 2026-02-17 06:56:48
言語 PyPy3
(7.3.17)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 807 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 412 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 59,856 KB
最終ジャッジ日時 2026-02-17 06:56:51
合計ジャッジ時間 2,537 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])
    
    if arr==[]:
        arr.append([n, 1])
        
    return arr

n = I()
ans = factorization(n)
a = 1
b = n
for x in ans:
    a *= x[0]**(x[1]//2)
    b //= x[0]**((x[1]//2)*2)

print(a, b)
0