結果

問題 No.368 LCM of K-products
ユーザー mkawa2mkawa2
提出日時 2020-03-19 21:04:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 1,120 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 73,596 KB
最終ジャッジ日時 2024-05-08 03:29:31
合計ジャッジ時間 3,512 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
70,108 KB
testcase_01 AC 124 ms
71,320 KB
testcase_02 AC 44 ms
57,084 KB
testcase_03 AC 84 ms
69,968 KB
testcase_04 AC 72 ms
73,008 KB
testcase_05 AC 284 ms
64,892 KB
testcase_06 AC 43 ms
59,780 KB
testcase_07 AC 43 ms
60,088 KB
testcase_08 AC 41 ms
55,896 KB
testcase_09 AC 41 ms
54,928 KB
testcase_10 AC 40 ms
53,932 KB
testcase_11 AC 39 ms
54,172 KB
testcase_12 AC 42 ms
60,332 KB
testcase_13 AC 67 ms
67,640 KB
testcase_14 AC 83 ms
70,008 KB
testcase_15 AC 91 ms
72,024 KB
testcase_16 AC 88 ms
71,284 KB
testcase_17 AC 79 ms
69,072 KB
testcase_18 AC 96 ms
72,836 KB
testcase_19 AC 54 ms
62,300 KB
testcase_20 AC 78 ms
67,468 KB
testcase_21 AC 52 ms
60,576 KB
testcase_22 AC 95 ms
73,596 KB
testcase_23 AC 40 ms
54,420 KB
testcase_24 AC 41 ms
54,904 KB
testcase_25 AC 40 ms
54,724 KB
testcase_26 AC 39 ms
53,868 KB
testcase_27 AC 38 ms
55,400 KB
testcase_28 AC 38 ms
54,736 KB
testcase_29 AC 40 ms
55,792 KB
testcase_30 AC 40 ms
55,628 KB
testcase_31 AC 39 ms
54,344 KB
testcase_32 AC 37 ms
54,652 KB
testcase_33 AC 58 ms
64,284 KB
testcase_34 AC 61 ms
69,592 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def pf(x):
    bb=[]
    ee=[]
    cnt2=(x&-x).bit_length()-1
    if cnt2:
        bb.append(2)
        ee.append(cnt2)
        x>>=cnt2
    b=3
    while b**2<=x:
        e=0
        while x%b==0:
            x//=b
            e+=1
        if e:
            bb.append(b)
            ee.append(e)
        b+=2
    if x>1:
        bb.append(x)
        ee.append(1)
    return bb,ee

def main():
    md=10**9+7
    n,k=MI()
    aa=LI()
    be=defaultdict(list)
    for a in aa:
        bb,ee=pf(a)
        for b,e in zip(bb,ee):
            be[b].append(e)
    ans=1
    for b,ee in be.items():
        ee.sort(reverse=True)
        s=sum(ee[:k])
        ans*=pow(b,s,md)
        ans%=md
    print(ans)

main()
0