結果

問題 No.368 LCM of K-products
ユーザー とりゐとりゐ
提出日時 2021-10-29 14:03:47
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 489 ms / 2,000 ms
コード長 623 bytes
コンパイル時間 228 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 77,440 KB
最終ジャッジ日時 2024-04-16 13:21:49
合計ジャッジ時間 7,522 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 299 ms
69,632 KB
testcase_01 AC 211 ms
71,808 KB
testcase_02 AC 372 ms
63,104 KB
testcase_03 AC 297 ms
69,888 KB
testcase_04 AC 281 ms
72,448 KB
testcase_05 AC 489 ms
64,000 KB
testcase_06 AC 50 ms
59,136 KB
testcase_07 AC 49 ms
59,392 KB
testcase_08 AC 47 ms
53,888 KB
testcase_09 AC 47 ms
54,144 KB
testcase_10 AC 47 ms
53,760 KB
testcase_11 AC 47 ms
53,760 KB
testcase_12 AC 51 ms
59,136 KB
testcase_13 AC 220 ms
66,304 KB
testcase_14 AC 312 ms
70,784 KB
testcase_15 AC 345 ms
73,728 KB
testcase_16 AC 304 ms
71,168 KB
testcase_17 AC 264 ms
69,376 KB
testcase_18 AC 363 ms
77,440 KB
testcase_19 AC 122 ms
61,952 KB
testcase_20 AC 253 ms
68,480 KB
testcase_21 AC 96 ms
60,928 KB
testcase_22 AC 350 ms
74,624 KB
testcase_23 AC 47 ms
53,888 KB
testcase_24 AC 46 ms
53,632 KB
testcase_25 AC 47 ms
53,888 KB
testcase_26 AC 50 ms
53,504 KB
testcase_27 AC 46 ms
53,632 KB
testcase_28 AC 46 ms
53,760 KB
testcase_29 AC 48 ms
53,760 KB
testcase_30 AC 47 ms
53,888 KB
testcase_31 AC 48 ms
53,888 KB
testcase_32 AC 46 ms
53,888 KB
testcase_33 AC 164 ms
64,000 KB
testcase_34 AC 79 ms
69,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def fact(n):
  #fact(18)=[[2, 1],[3, 2]] (18 = 2**1 * 3**2)
  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])
  if arr==[]:
    arr.append([n, 1])
  return arr

from collections import defaultdict
n,k=map(int,input().split())
a=list(map(int,input().split()))
d=defaultdict(list)
for i in a:
  for p,m in fact(i):
    d[p].append(m)
mod=10**9+7
ans=1
for i in d:
  x=sorted(d[i],reverse=True)
  ans*=pow(i,sum(x[:min(len(x),k)]),mod)
  ans%=mod
print(ans)
0