結果
問題 | No.368 LCM of K-products |
ユーザー | mai |
提出日時 | 2018-02-02 00:42:04 |
言語 | Ruby (3.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 550 bytes |
コンパイル時間 | 67 ms |
コンパイル使用メモリ | 11,244 KB |
実行使用メモリ | 20,116 KB |
最終ジャッジ日時 | 2023-08-28 18:05:25 |
合計ジャッジ時間 | 5,937 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 348 ms
19,844 KB |
testcase_01 | AC | 1,010 ms
15,704 KB |
testcase_02 | AC | 96 ms
15,412 KB |
testcase_03 | AC | 362 ms
15,480 KB |
testcase_04 | AC | 163 ms
15,588 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
ソースコード
def ascan; gets.split.map(&:to_i);end def mypow(x,w,md) y=1 while 0<w y = (x*y)%md if w.odd? w/=2 x = (x*x)%md end y 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 *= mypow(k,(v.sort.pop(K).reduce(:+)),MD) ans %= MD end p ans # case # 3 2 # 100 11 10