結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー ntudantuda
提出日時 2021-12-10 19:42:12
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,716 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 87,092 KB
実行使用メモリ 81,760 KB
最終ジャッジ日時 2023-09-25 16:53:15
合計ジャッジ時間 10,577 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 283 ms
78,916 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 250 ms
79,932 KB
testcase_11 AC 230 ms
79,404 KB
testcase_12 AC 236 ms
79,800 KB
testcase_13 AC 262 ms
80,564 KB
testcase_14 AC 252 ms
79,908 KB
testcase_15 AC 238 ms
80,380 KB
testcase_16 AC 243 ms
80,024 KB
testcase_17 AC 276 ms
81,760 KB
testcase_18 AC 239 ms
80,116 KB
testcase_19 AC 98 ms
76,684 KB
testcase_20 AC 93 ms
76,588 KB
testcase_21 AC 100 ms
77,000 KB
testcase_22 AC 101 ms
76,756 KB
testcase_23 AC 93 ms
76,544 KB
testcase_24 AC 94 ms
76,716 KB
testcase_25 AC 92 ms
76,452 KB
testcase_26 AC 94 ms
76,608 KB
testcase_27 AC 98 ms
76,828 KB
testcase_28 AC 70 ms
71,480 KB
testcase_29 AC 71 ms
71,504 KB
testcase_30 AC 72 ms
71,300 KB
testcase_31 AC 71 ms
71,480 KB
testcase_32 AC 74 ms
71,248 KB
testcase_33 AC 75 ms
71,248 KB
testcase_34 AC 70 ms
71,308 KB
testcase_35 AC 73 ms
71,244 KB
testcase_36 AC 72 ms
71,304 KB
testcase_37 AC 72 ms
71,292 KB
testcase_38 AC 73 ms
71,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
PL = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31,37]
fmin = 10 ** 18
N = [int(input()) for _ in range(T)]

for n2 in N:
    n = n2
    dic = {}
    for p in PL:
        cnt = 0
        while n % p == 0:
            n //= p
            cnt += 1
        if cnt == 0:
            # 素因数に含まれない最小の素数
            fmin = p
            break
        #dic[0].remove(p)
        if cnt in dic:
            dic[cnt].add(p)
        else:
            dic[cnt] = {p}


    d1,d2,d3,d4 = 0,0,0,0

    # 素因数の数が1の最小の素数の2乗
    if 1 in dic:
        d1 = min(dic[1])
        fmin = min(fmin, d1 ** 2)
    # 素因数の数が2の最小の素数の3乗
    if 2 in dic:
        d2 = min(dic[2])
        fmin = min(fmin, d2 ** 3)
    # 素因数の数が3の最小の素数の4乗
    if 3 in dic:
        d3 = min(dic[3])
        fmin = min(fmin, d3 ** 4)
    # 素因数の数が1の最小の素数と素因数の数が2の最小の素数の積
    if d1 != 0 and d2 != 0:
        fmin = min(fmin, d1 * d2)
    # 素因数の数が2の最小の素数と素因数の数が3の最小の素数の積
    if d2 != 0 and d3 != 0:
        fmin = min(fmin, d2 * d3 ** 2)
    # 素因数の数が2の最小の素数と素因数の数が3の最小の素数の積
    if d3 != 0 and d4 != 0:
        fmin = min(fmin, d3 * d4 ** 3)
    # 素因数の数が2の最小の素数と素因数の数が3の最小の素数の積
    if d2 != 0 and d3 != 0 and d4 != 0:
        fmin = min(fmin, d2 * d3 * d4)
    # 素因数の数が2の最小の素数と素因数の数が3の最小の素数の積
    if d2 != 0 and d4 != 0:
        fmin = min(fmin, d4 * d2 ** 2)


    print(fmin * n2)
0