結果

問題 No.368 LCM of K-products
ユーザー rlangevinrlangevin
提出日時 2023-10-13 08:53:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 597 ms / 2,000 ms
コード長 748 bytes
コンパイル時間 652 ms
コンパイル使用メモリ 87,136 KB
実行使用メモリ 78,660 KB
最終ジャッジ日時 2023-10-13 08:54:05
合計ジャッジ時間 10,244 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 361 ms
78,336 KB
testcase_01 AC 265 ms
78,500 KB
testcase_02 AC 487 ms
76,996 KB
testcase_03 AC 368 ms
77,988 KB
testcase_04 AC 346 ms
78,488 KB
testcase_05 AC 597 ms
76,972 KB
testcase_06 AC 94 ms
76,820 KB
testcase_07 AC 95 ms
76,692 KB
testcase_08 AC 89 ms
71,940 KB
testcase_09 AC 89 ms
72,176 KB
testcase_10 AC 89 ms
72,024 KB
testcase_11 AC 90 ms
71,944 KB
testcase_12 AC 96 ms
76,840 KB
testcase_13 AC 286 ms
78,028 KB
testcase_14 AC 379 ms
78,208 KB
testcase_15 AC 414 ms
78,660 KB
testcase_16 AC 379 ms
78,288 KB
testcase_17 AC 332 ms
78,508 KB
testcase_18 AC 437 ms
78,544 KB
testcase_19 AC 174 ms
77,208 KB
testcase_20 AC 317 ms
78,244 KB
testcase_21 AC 146 ms
77,316 KB
testcase_22 AC 419 ms
78,464 KB
testcase_23 AC 92 ms
72,060 KB
testcase_24 AC 91 ms
72,172 KB
testcase_25 AC 92 ms
71,840 KB
testcase_26 AC 90 ms
71,856 KB
testcase_27 AC 91 ms
71,952 KB
testcase_28 AC 91 ms
72,016 KB
testcase_29 AC 91 ms
72,216 KB
testcase_30 AC 89 ms
72,056 KB
testcase_31 AC 90 ms
72,076 KB
testcase_32 AC 89 ms
71,684 KB
testcase_33 AC 218 ms
77,872 KB
testcase_34 AC 119 ms
78,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
 
    if temp != 1:
        arr.append([temp, 1])

    return arr


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

from collections import *
D = defaultdict(list)
for a in A:
    for k, v in factorization(a):
        D[k].append(v)

ans = 1
mod = 10 ** 9 + 7
for k, v in D.items():
    if len(v) <= K:
        ans *= pow(k, sum(v), mod)
        ans %= mod
    else:
        v.sort(reverse=True)
        ans *= pow(k, sum(v[:K]), mod)
        ans %= mod

print(ans)
0