結果

問題 No.368 LCM of K-products
ユーザー maimai
提出日時 2018-02-02 00:37:50
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 422 bytes
コンパイル時間 52 ms
コンパイル使用メモリ 11,332 KB
実行使用メモリ 20,032 KB
最終ジャッジ日時 2023-08-28 18:05:17
合計ジャッジ時間 6,179 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 359 ms
15,540 KB
testcase_01 AC 1,004 ms
15,752 KB
testcase_02 AC 103 ms
15,744 KB
testcase_03 AC 370 ms
15,528 KB
testcase_04 AC 164 ms
15,664 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i);end

require 'prime'

MD = 1000000007

N,K = ascan
aa = ascan.sort

# p aa.combination(K).map{|z| z.reduce(:*)}.reduce(:lcm)%MD

primes = aa.reduce({}) do |s,a|
    Prime.prime_division(a).each do |k,v|
        s[k] ||= []
        s[k] << v
    end
    s
end

ans = 1

primes.each do |k, v|
    ans *= (k**(v.sort.pop(K).reduce(:+)))%MD
    ans %= MD
end

p ans

# case
# 3 2
# 100 11 10
0