結果

問題 No.1063 ルートの計算 / Sqrt Calculation
ユーザー yomo3yomo3
提出日時 2020-06-02 11:48:49
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 17 ms / 2,000 ms
コード長 528 bytes
コンパイル時間 176 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 7,896 KB
最終ジャッジ日時 2023-08-15 11:37:29
合計ジャッジ時間 1,258 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,740 KB
testcase_01 AC 16 ms
7,896 KB
testcase_02 AC 17 ms
7,796 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,792 KB
testcase_05 AC 15 ms
7,820 KB
testcase_06 AC 15 ms
7,760 KB
testcase_07 AC 16 ms
7,804 KB
testcase_08 AC 15 ms
7,756 KB
testcase_09 AC 16 ms
7,816 KB
testcase_10 AC 16 ms
7,852 KB
testcase_11 AC 16 ms
7,820 KB
testcase_12 AC 16 ms
7,820 KB
testcase_13 AC 16 ms
7,808 KB
testcase_14 AC 15 ms
7,796 KB
testcase_15 AC 15 ms
7,816 KB
testcase_16 AC 15 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factors(n):
    f = []
    c = 0
    while n % 2 == 0:
        n //= 2
        c += 1
    if c > 0:
        f.append([2, c])
    p = 3
    while p * p <= n:
        if n % p == 0:
            c = 0
            while n % p == 0:
                n //= p
                c += 1
            if c > 0:
                f.append([p, c])
        p += 2
    if n != 1:
        f.append([n, 1])
    return f

N = int(input())

a = b = 1
for p, x in factors(N):
    a *= int(pow(p, x//2))
    if x % 2 == 1:
        b *=  p
print(a, b)
0