結果

問題 No.1611 Minimum Multiple with Double Divisors
ユーザー lloyzlloyz
提出日時 2021-12-31 01:06:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 630 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 200 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,336 KB
最終ジャッジ日時 2024-04-16 11:13:10
合計ジャッジ時間 13,448 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 630 ms
77,056 KB
testcase_01 AC 465 ms
77,012 KB
testcase_02 AC 486 ms
77,520 KB
testcase_03 AC 466 ms
77,388 KB
testcase_04 AC 469 ms
77,056 KB
testcase_05 AC 469 ms
77,388 KB
testcase_06 AC 466 ms
77,004 KB
testcase_07 AC 483 ms
77,056 KB
testcase_08 AC 470 ms
77,236 KB
testcase_09 AC 466 ms
77,056 KB
testcase_10 AC 408 ms
77,184 KB
testcase_11 AC 404 ms
77,184 KB
testcase_12 AC 425 ms
78,080 KB
testcase_13 AC 445 ms
78,336 KB
testcase_14 AC 447 ms
78,336 KB
testcase_15 AC 409 ms
77,696 KB
testcase_16 AC 404 ms
77,568 KB
testcase_17 AC 424 ms
77,824 KB
testcase_18 AC 427 ms
77,312 KB
testcase_19 AC 119 ms
77,696 KB
testcase_20 AC 109 ms
77,056 KB
testcase_21 AC 116 ms
76,800 KB
testcase_22 AC 109 ms
76,800 KB
testcase_23 AC 121 ms
77,184 KB
testcase_24 AC 118 ms
77,312 KB
testcase_25 AC 112 ms
76,928 KB
testcase_26 AC 111 ms
76,800 KB
testcase_27 AC 119 ms
77,056 KB
testcase_28 AC 46 ms
53,632 KB
testcase_29 AC 47 ms
53,888 KB
testcase_30 AC 47 ms
53,632 KB
testcase_31 AC 47 ms
53,760 KB
testcase_32 AC 46 ms
53,760 KB
testcase_33 AC 46 ms
53,760 KB
testcase_34 AC 46 ms
53,632 KB
testcase_35 AC 46 ms
53,760 KB
testcase_36 AC 46 ms
53,888 KB
testcase_37 AC 46 ms
53,760 KB
testcase_38 AC 46 ms
53,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict

def prime_factorization(n):
    prime_cnt_dict = defaultdict(int)
    if n == 0 or n == 1:
        return prime_cnt_dict
    nc = n
    while nc % 2 == 0:
        nc //= 2
        prime_cnt_dict[2] += 1
    f = 3
    while f * f <= n:
        cnt = 0
        while nc % f == 0:
            nc //= f
            prime_cnt_dict[f] += 1
        f += 2
    if nc != 1:
        prime_cnt_dict[nc] = 1
    return prime_cnt_dict

Prime = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31]
PrimeCountList = [prime_factorization(i) for i in range(32)]
t = int(input())
for _ in range(t):
    x = int(input())
    x_prime_cnt_dict = defaultdict(int)
    for prime in Prime:
        xc = x
        while xc % prime == 0:
            xc //= prime
            x_prime_cnt_dict[prime] += 1
    for i in range(2, 32):
        x_cnt = 1
        x_i_cnt = 1
        for prime in PrimeCountList[i]:
            x_cnt *= x_prime_cnt_dict[prime] + 1
            x_i_cnt *= x_prime_cnt_dict[prime] + PrimeCountList[i][prime] + 1
        if 2 * x_cnt == x_i_cnt:
            break
    print(x * i)

    
0