結果

問題 No.368 LCM of K-products
ユーザー mkawa2mkawa2
提出日時 2020-03-19 21:03:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,120 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 9,072 KB
最終ジャッジ日時 2023-08-20 21:07:20
合計ジャッジ時間 7,207 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 176 ms
8,844 KB
testcase_01 AC 571 ms
9,072 KB
testcase_02 AC 20 ms
8,636 KB
testcase_03 AC 186 ms
8,636 KB
testcase_04 AC 58 ms
8,804 KB
testcase_05 TLE -
testcase_06 AC 19 ms
8,656 KB
testcase_07 AC 22 ms
8,480 KB
testcase_08 AC 19 ms
8,692 KB
testcase_09 AC 19 ms
8,548 KB
testcase_10 AC 19 ms
8,652 KB
testcase_11 AC 18 ms
8,676 KB
testcase_12 AC 19 ms
8,632 KB
testcase_13 AC 134 ms
8,632 KB
testcase_14 AC 208 ms
8,668 KB
testcase_15 AC 226 ms
8,724 KB
testcase_16 AC 188 ms
8,880 KB
testcase_17 AC 176 ms
8,768 KB
testcase_18 AC 235 ms
8,756 KB
testcase_19 AC 69 ms
8,576 KB
testcase_20 AC 175 ms
8,700 KB
testcase_21 AC 58 ms
8,696 KB
testcase_22 AC 226 ms
8,816 KB
testcase_23 AC 19 ms
8,540 KB
testcase_24 AC 19 ms
8,676 KB
testcase_25 AC 19 ms
8,560 KB
testcase_26 AC 19 ms
8,528 KB
testcase_27 AC 19 ms
8,520 KB
testcase_28 AC 19 ms
8,600 KB
testcase_29 AC 19 ms
8,688 KB
testcase_30 AC 19 ms
8,656 KB
testcase_31 AC 19 ms
8,540 KB
testcase_32 AC 19 ms
8,696 KB
testcase_33 AC 97 ms
8,632 KB
testcase_34 AC 21 ms
8,568 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