結果

問題 No.368 LCM of K-products
ユーザー vwxyz
提出日時 2022-09-28 22:51:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 613 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 21,376 KB
最終ジャッジ日時 2024-12-22 17:49:26
合計ジャッジ時間 12,183 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import sys
readline=sys.stdin.readline

def Factorize(N):
    assert N>=1
    factors=defaultdict(int)
    for p in range(2,N):
        if p**2>N:
            break
        while N%p==0:
            factors[p]+=1
            N//=p
    if N!=1:
        factors[N]+=1
    return factors

N,K=map(int,readline().split())
A=list(map(int,readline().split()))
dct=defaultdict(list)
for a in A:
    for p,e in Factorize(a).items():
        dct[p].append(e)
ans=1
mod=10**9+7
for p,lst in dct.items():
    lst.sort(reverse=True)
    ans*=pow(p,sum(lst[:K]),mod)
    ans%=mod
print(ans)
0