結果

問題 No.368 LCM of K-products
ユーザー 🍡yurahuna
提出日時 2016-04-05 20:28:15
言語 Python2
(2.7.18)
結果
TLE  
実行時間 -
コード長 657 bytes
コンパイル時間 347 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 13,736 KB
最終ジャッジ日時 2024-10-04 01:58:45
合計ジャッジ時間 7,599 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as ddict

N, K = map(int, raw_input().split())
a = list(map(int, raw_input().split()))

exponents = ddict(list)
for ax in a:
    # primeFactrization
    cnt = ddict(int)
    i = 2
    while i * i <= ax:
        while ax % i == 0:
            cnt[i] +=  1
            ax /= i
        i += 1
    if ax != 1:
        cnt[ax] += 1

    for key, value in cnt.items():
        exponents[key].append(value)



mod = 10**9 + 7

ans = 1
for prime, li in exponents.items():
    li.sort(reverse = True)
    num = 0
    for i in range(min(K, len(li))):
        num += li[i]

    ans *= pow(prime, num, mod)
    ans %= mod

print ans
0