結果

問題 No.368 LCM of K-products
ユーザー vwxyzvwxyz
提出日時 2022-09-28 22:51:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 637 ms / 2,000 ms
コード長 613 bytes
コンパイル時間 529 ms
コンパイル使用メモリ 87,024 KB
実行使用メモリ 78,132 KB
最終ジャッジ日時 2023-08-24 04:37:11
合計ジャッジ時間 7,027 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 164 ms
78,132 KB
testcase_01 AC 268 ms
77,868 KB
testcase_02 AC 109 ms
77,016 KB
testcase_03 AC 170 ms
78,060 KB
testcase_04 AC 139 ms
77,968 KB
testcase_05 AC 637 ms
77,200 KB
testcase_06 AC 97 ms
76,756 KB
testcase_07 AC 102 ms
76,968 KB
testcase_08 AC 94 ms
71,644 KB
testcase_09 AC 93 ms
71,596 KB
testcase_10 AC 94 ms
71,588 KB
testcase_11 AC 94 ms
71,428 KB
testcase_12 AC 100 ms
76,852 KB
testcase_13 AC 146 ms
77,784 KB
testcase_14 AC 173 ms
77,928 KB
testcase_15 AC 188 ms
78,128 KB
testcase_16 AC 172 ms
77,968 KB
testcase_17 AC 161 ms
77,660 KB
testcase_18 AC 191 ms
78,112 KB
testcase_19 AC 119 ms
77,016 KB
testcase_20 AC 162 ms
77,752 KB
testcase_21 AC 112 ms
76,824 KB
testcase_22 AC 190 ms
78,004 KB
testcase_23 AC 95 ms
71,264 KB
testcase_24 AC 91 ms
71,756 KB
testcase_25 AC 91 ms
71,644 KB
testcase_26 AC 94 ms
71,768 KB
testcase_27 AC 96 ms
71,616 KB
testcase_28 AC 95 ms
71,568 KB
testcase_29 AC 93 ms
71,268 KB
testcase_30 AC 92 ms
71,704 KB
testcase_31 AC 93 ms
71,652 KB
testcase_32 AC 91 ms
71,776 KB
testcase_33 AC 128 ms
77,632 KB
testcase_34 AC 120 ms
77,880 KB
権限があれば一括ダウンロードができます

ソースコード

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