結果

問題 No.368 LCM of K-products
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-17 22:02:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,306 ms / 2,000 ms
コード長 728 bytes
コンパイル時間 1,282 ms
コンパイル使用メモリ 86,808 KB
実行使用メモリ 302,240 KB
最終ジャッジ日時 2023-08-20 03:52:28
合計ジャッジ時間 14,993 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 403 ms
80,600 KB
testcase_01 AC 1,158 ms
302,240 KB
testcase_02 AC 507 ms
78,276 KB
testcase_03 AC 847 ms
110,068 KB
testcase_04 AC 1,306 ms
162,464 KB
testcase_05 AC 933 ms
163,984 KB
testcase_06 AC 134 ms
76,548 KB
testcase_07 AC 97 ms
76,552 KB
testcase_08 AC 92 ms
72,068 KB
testcase_09 AC 91 ms
72,064 KB
testcase_10 AC 95 ms
71,700 KB
testcase_11 AC 93 ms
71,852 KB
testcase_12 AC 98 ms
76,764 KB
testcase_13 AC 332 ms
81,188 KB
testcase_14 AC 520 ms
86,192 KB
testcase_15 AC 910 ms
146,576 KB
testcase_16 AC 501 ms
85,424 KB
testcase_17 AC 372 ms
80,936 KB
testcase_18 AC 649 ms
102,440 KB
testcase_19 AC 209 ms
78,432 KB
testcase_20 AC 423 ms
85,248 KB
testcase_21 AC 170 ms
77,948 KB
testcase_22 AC 633 ms
102,032 KB
testcase_23 AC 92 ms
71,656 KB
testcase_24 AC 92 ms
71,960 KB
testcase_25 AC 90 ms
72,072 KB
testcase_26 AC 92 ms
71,884 KB
testcase_27 AC 93 ms
71,664 KB
testcase_28 AC 90 ms
72,060 KB
testcase_29 AC 94 ms
71,872 KB
testcase_30 AC 95 ms
71,744 KB
testcase_31 AC 92 ms
72,180 KB
testcase_32 AC 91 ms
72,008 KB
testcase_33 AC 215 ms
78,100 KB
testcase_34 AC 226 ms
81,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict


def prime_factorization(n):  # 素因数分解
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        if n % i == 0:
            cnt = 0
            while n % i == 0:
                cnt += 1
                n //= i
            res.append((i, cnt))
    if n > 1:
        res.append((n, 1))
    return res


N, K = map(int, input().split())
A = list(map(int, input().split()))

dp = [defaultdict(int) for _ in range(K+1)]
for a in A:
    pf = prime_factorization(a)
    for i in reversed(range(K)):
        for p, f in pf:
            dp[i+1][p] = max(dp[i+1][p], dp[i][p] + f)

mod = 10 ** 9 + 7
ans = 1
for k, v in dp[K].items():
    ans *= pow(k, v, mod)
    ans %= mod
print(ans)
0