結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー nikkuniku029nikkuniku029
提出日時 2020-06-06 08:10:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 839 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 7,964 KB
最終ジャッジ日時 2023-08-24 17:09:51
合計ジャッジ時間 1,148 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,936 KB
testcase_01 AC 15 ms
7,912 KB
testcase_02 AC 16 ms
7,928 KB
testcase_03 AC 18 ms
7,908 KB
testcase_04 AC 16 ms
7,880 KB
testcase_05 AC 18 ms
7,820 KB
testcase_06 AC 15 ms
7,928 KB
testcase_07 AC 17 ms
7,964 KB
testcase_08 AC 17 ms
7,828 KB
testcase_09 AC 16 ms
7,884 KB
testcase_10 AC 17 ms
7,856 KB
testcase_11 AC 16 ms
7,776 KB
testcase_12 AC 17 ms
7,880 KB
testcase_13 AC 16 ms
7,836 KB
testcase_14 AC 17 ms
7,784 KB
testcase_15 AC 16 ms
7,908 KB
testcase_16 AC 16 ms
7,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())


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

a=factorization(n)

ans=1
ans2=1
for i in a:
    if i[1]%2==1:
        if i[1]>2:
            ans2*=i[0]**(i[1]//2)
            ans*=i[0]
        else:
            ans*=i[0]
    else:
        ans2*=i[0]**(i[1]//2)

print(ans2,ans)
0