結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー hir355hir355
提出日時 2021-07-21 22:10:25
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 963 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 80,540 KB
最終ジャッジ日時 2023-09-24 17:56:57
合計ジャッジ時間 12,597 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 396 ms
77,932 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 354 ms
78,256 KB
testcase_11 AC 352 ms
77,844 KB
testcase_12 AC 386 ms
80,540 KB
testcase_13 AC 395 ms
79,496 KB
testcase_14 AC 358 ms
78,020 KB
testcase_15 AC 355 ms
78,368 KB
testcase_16 AC 354 ms
77,844 KB
testcase_17 AC 364 ms
78,292 KB
testcase_18 AC 358 ms
78,088 KB
testcase_19 AC 99 ms
77,012 KB
testcase_20 AC 99 ms
76,996 KB
testcase_21 AC 112 ms
78,060 KB
testcase_22 AC 97 ms
76,800 KB
testcase_23 AC 100 ms
76,820 KB
testcase_24 AC 98 ms
76,620 KB
testcase_25 AC 114 ms
78,788 KB
testcase_26 AC 99 ms
76,700 KB
testcase_27 AC 112 ms
77,948 KB
testcase_28 AC 70 ms
71,524 KB
testcase_29 AC 69 ms
71,644 KB
testcase_30 AC 69 ms
71,700 KB
testcase_31 AC 70 ms
71,436 KB
testcase_32 AC 70 ms
71,608 KB
testcase_33 AC 69 ms
71,664 KB
testcase_34 AC 71 ms
71,816 KB
testcase_35 AC 71 ms
71,612 KB
testcase_36 AC 68 ms
71,820 KB
testcase_37 AC 69 ms
71,572 KB
testcase_38 AC 70 ms
71,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

pr = primes(200)
t = int(input())
for _ in range(t):
    x = int(input())
    ans = 10 ** 18
    l = [(0, 100000)]
    for p in pr:
        cnt = 1
        t = x
        while t % p == 0:
            t //= p
            cnt += 1
        if l[-1][1] > cnt:
            res = x
            l.append((p, cnt))
            for i in range(len(l) - 1, 0, -1):
                if l[i - 1][1] >= cnt * 2:
                    res *= pow(l[i][0], cnt * 2 - l[i][1])
                    break
                else:
                    res *= pow(l[i][0], l[i - 1][1] - l[i][1])
            ans = min(ans, res)
        if x % p > 0:
            break
    print(ans)
0