結果
問題 |
No.368 LCM of K-products
|
ユーザー |
|
提出日時 | 2022-03-30 16:41:51 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 178 ms / 2,000 ms |
コード長 | 781 bytes |
コンパイル時間 | 424 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 71,808 KB |
最終ジャッジ日時 | 2024-11-15 06:11:50 |
合計ジャッジ時間 | 5,337 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
N,K = map(int,input().split()) P = 10 ** 9 + 7 ans = 1 a = list(map(int,input().split())) C = 4 * 10 ** 4 dat = [0] * C for i in range(2,C): if dat[i] == 0: for j in range(2 * i,C,i): dat[j] = 1 l = [] for j in range(N): count = 0 while a[j] % i == 0: count += 1 a[j] //= i if count: l.append(count) l.sort(reverse = True) _sum = 0 for j in l[:K]: _sum += j ans = ans * pow(i,_sum,P) % P from collections import defaultdict d = defaultdict(int) for i in a: if i > 1: d[i] += 1 for i in d: if d[i] > K: ans = ans * pow(i,K,P) % P else: ans = ans * pow(i,d[i],P) % P print(ans)