結果

問題 No.368 LCM of K-products
ユーザー rlangevinrlangevin
提出日時 2023-09-04 12:19:39
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 1,043 ms
コンパイル使用メモリ 86,664 KB
実行使用メモリ 76,392 KB
最終ジャッジ日時 2023-09-04 12:19:46
合計ジャッジ時間 5,718 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 76 ms
71,276 KB
testcase_02 AC 74 ms
71,192 KB
testcase_03 AC 74 ms
71,140 KB
testcase_04 AC 74 ms
71,108 KB
testcase_05 AC 74 ms
71,192 KB
testcase_06 AC 74 ms
71,204 KB
testcase_07 AC 74 ms
70,968 KB
testcase_08 AC 74 ms
71,256 KB
testcase_09 AC 90 ms
71,156 KB
testcase_10 AC 72 ms
71,144 KB
testcase_11 AC 73 ms
71,268 KB
testcase_12 AC 73 ms
71,216 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 75 ms
71,140 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 72 ms
71,200 KB
testcase_24 AC 74 ms
71,152 KB
testcase_25 WA -
testcase_26 AC 76 ms
71,280 KB
testcase_27 AC 74 ms
70,960 KB
testcase_28 AC 75 ms
71,340 KB
testcase_29 AC 76 ms
71,256 KB
testcase_30 WA -
testcase_31 AC 76 ms
71,348 KB
testcase_32 AC 75 ms
71,276 KB
testcase_33 WA -
testcase_34 AC 74 ms
71,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

N, K = map(int, input().split())
mod = 10 ** 9 + 7
A = list(map(int, input().split()))
if K == 1:
    for i in range(N):
        for j in range(i + 1, N):
            g = gcd(A[i], A[j])
            A[i] //= g
    ans = 1
    for i in range(N):
        ans *= A[i]
        ans %= mod
    print(ans)
    exit()

g = A[0]
ans = 1
for i in range(N):
    g = gcd(g, A[i])
    ans *= A[i]
    ans %= mod

ans *= pow(g, (mod - 2) * (N - K), mod)
print(ans%mod)
0