結果
| 問題 |
No.368 LCM of K-products
|
| コンテスト | |
| ユーザー |
🍡yurahuna
|
| 提出日時 | 2016-04-05 20:29:54 |
| 言語 | PyPy2 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 621 ms / 2,000 ms |
| コード長 | 657 bytes |
| コンパイル時間 | 1,068 ms |
| コンパイル使用メモリ | 76,792 KB |
| 実行使用メモリ | 80,676 KB |
| 最終ジャッジ日時 | 2024-09-22 14:41:03 |
| 合計ジャッジ時間 | 6,654 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 35 |
ソースコード
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
🍡yurahuna