結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー tktk_snsntktk_snsn
提出日時 2021-09-21 13:18:56
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 208 ms
コンパイル使用メモリ 10,828 KB
実行使用メモリ 51,956 KB
最終ジャッジ日時 2023-09-16 21:38:49
合計ジャッジ時間 20,514 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,561 ms
51,840 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 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 168 ms
51,804 KB
testcase_29 AC 171 ms
51,808 KB
testcase_30 AC 175 ms
51,888 KB
testcase_31 AC 177 ms
51,872 KB
testcase_32 AC 175 ms
51,816 KB
testcase_33 AC 174 ms
51,752 KB
testcase_34 AC 169 ms
51,944 KB
testcase_35 WA -
testcase_36 AC 175 ms
51,944 KB
testcase_37 AC 174 ms
51,804 KB
testcase_38 AC 174 ms
51,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import chain
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 18


def prime_set(N):
    """
    Nまでの素数のsetを返す
    """
    if N < 4:
        return ({}, {}, {2}, {2, 3})[N]
    Nsq = int(N ** 0.5 + 0.5) + 1
    primes = {2, 3} | set(chain(range(5, N + 1, 6), range(7, N + 1, 6)))
    for i in range(5, Nsq, 2):
        if i in primes:
            primes -= set(range(i * i, N + 1, i * 2))
    return sorted(primes)


def F(n, p):
    res = 1
    for _ in range(p):
        res *= n
        if res > inf:
            return inf
    return res


U = 10 ** 6
Prime = prime_set(U)
T = int(input())
for _ in range(T):
    X = int(input())
    ans = X
    D = inf
    for p in Prime:
        if p >= D:
            break
        cnt = 0
        while X % p == 0:
            cnt += 1
            X //= p
        D = min(D, F(p, cnt + 1))
    print(ans * D)
0