結果

問題 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
コンパイル時間 81 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-05-08 03:29:19
合計ジャッジ時間 8,465 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 242 ms
11,008 KB
testcase_01 AC 786 ms
11,392 KB
testcase_02 AC 30 ms
10,880 KB
testcase_03 AC 248 ms
11,008 KB
testcase_04 AC 80 ms
11,136 KB
testcase_05 TLE -
testcase_06 AC 29 ms
11,008 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 27 ms
10,880 KB
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 28 ms
10,880 KB
testcase_11 AC 29 ms
10,880 KB
testcase_12 AC 29 ms
10,880 KB
testcase_13 AC 181 ms
10,880 KB
testcase_14 AC 280 ms
11,264 KB
testcase_15 AC 306 ms
11,008 KB
testcase_16 AC 255 ms
11,136 KB
testcase_17 AC 236 ms
11,008 KB
testcase_18 AC 318 ms
11,008 KB
testcase_19 AC 98 ms
10,880 KB
testcase_20 AC 230 ms
11,008 KB
testcase_21 AC 79 ms
10,880 KB
testcase_22 AC 304 ms
11,136 KB
testcase_23 AC 29 ms
10,880 KB
testcase_24 AC 28 ms
11,008 KB
testcase_25 AC 28 ms
10,880 KB
testcase_26 AC 28 ms
11,008 KB
testcase_27 AC 28 ms
11,008 KB
testcase_28 AC 30 ms
10,880 KB
testcase_29 AC 30 ms
11,008 KB
testcase_30 AC 27 ms
10,880 KB
testcase_31 AC 28 ms
10,880 KB
testcase_32 AC 28 ms
11,008 KB
testcase_33 AC 132 ms
10,880 KB
testcase_34 AC 32 ms
11,136 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