結果

問題 No.368 LCM of K-products
ユーザー simansiman
提出日時 2022-07-22 15:34:20
言語 Ruby
(3.3.0)
結果
AC  
実行時間 888 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 55 ms
コンパイル使用メモリ 11,240 KB
実行使用メモリ 15,656 KB
最終ジャッジ日時 2023-09-17 00:49:09
合計ジャッジ時間 7,098 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 243 ms
15,496 KB
testcase_01 AC 888 ms
15,588 KB
testcase_02 AC 82 ms
15,488 KB
testcase_03 AC 312 ms
15,280 KB
testcase_04 AC 133 ms
15,420 KB
testcase_05 AC 78 ms
15,380 KB
testcase_06 AC 77 ms
15,400 KB
testcase_07 AC 79 ms
15,584 KB
testcase_08 AC 76 ms
15,184 KB
testcase_09 AC 76 ms
15,180 KB
testcase_10 AC 79 ms
15,096 KB
testcase_11 AC 78 ms
15,240 KB
testcase_12 AC 78 ms
15,272 KB
testcase_13 AC 193 ms
15,592 KB
testcase_14 AC 270 ms
15,444 KB
testcase_15 AC 284 ms
15,404 KB
testcase_16 AC 252 ms
15,476 KB
testcase_17 AC 221 ms
15,404 KB
testcase_18 AC 311 ms
15,656 KB
testcase_19 AC 133 ms
15,448 KB
testcase_20 AC 234 ms
15,344 KB
testcase_21 AC 118 ms
15,580 KB
testcase_22 AC 301 ms
15,440 KB
testcase_23 AC 83 ms
15,364 KB
testcase_24 AC 78 ms
15,180 KB
testcase_25 AC 79 ms
15,292 KB
testcase_26 AC 76 ms
15,392 KB
testcase_27 AC 77 ms
15,204 KB
testcase_28 AC 79 ms
15,200 KB
testcase_29 AC 82 ms
15,128 KB
testcase_30 AC 80 ms
15,336 KB
testcase_31 AC 80 ms
15,288 KB
testcase_32 AC 78 ms
15,172 KB
testcase_33 AC 156 ms
15,552 KB
testcase_34 AC 100 ms
15,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

N, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
MOD = 10 ** 9 + 7

counter = Hash.new { |h, k| h[k] = [] }

A.each do |a|
  if a.prime?
    counter[a] << 1
  else
    a.prime_division.each do |e, cnt|
      counter[e] << cnt
    end
  end
end

ans = 1

counter.each do |e, nums|
  cnt = nums.sort.pop(K).sum
  ans *= e.pow(cnt, MOD)
  ans %= MOD
end

puts ans
0