結果

問題 No.368 LCM of K-products
ユーザー nebukuro09nebukuro09
提出日時 2016-10-21 14:11:40
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 630 bytes
コンパイル時間 514 ms
コンパイル使用メモリ 6,944 KB
実行使用メモリ 13,468 KB
最終ジャッジ日時 2024-05-02 21:56:31
合計ジャッジ時間 6,315 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 293 ms
12,032 KB
testcase_01 AC 999 ms
6,912 KB
testcase_02 AC 19 ms
6,400 KB
testcase_03 AC 310 ms
6,656 KB
testcase_04 AC 85 ms
6,400 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10**9+7

def prime_decomposition(n):
    i = 2
    table = {}
    while i * i <= n:
        while n % i == 0:
            n /= i
            table[i] = table.get(i, 0) + 1
        i += 1
    if n > 1:
        table[n] = table.get(n, 0) + 1
    return table

N, K = map(int, raw_input().split())
A = map(int, raw_input().split())
d = {}
for a in A:
    for k, v in prime_decomposition(a).items():
        if k in d:
            d[k].append(v)
        else:
            d[k] = [v]

ans = 1
for k, v in d.items():
    nv = sorted(v, reverse=True)
    for i in xrange(min(K, len(v))):
        ans = ans*k**nv[i] % MOD
print ans
0