結果

問題 No.811 約数の個数の最大化
ユーザー letrangerjpletrangerjp
提出日時 2019-04-12 21:55:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 378 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,436 KB
実行使用メモリ 15,608 KB
最終ジャッジ日時 2023-10-12 20:03:41
合計ジャッジ時間 8,407 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 94 ms
15,440 KB
testcase_02 AC 996 ms
15,388 KB
testcase_03 WA -
testcase_04 AC 93 ms
15,496 KB
testcase_05 AC 105 ms
15,564 KB
testcase_06 AC 141 ms
15,404 KB
testcase_07 AC 172 ms
15,544 KB
testcase_08 AC 498 ms
15,608 KB
testcase_09 AC 531 ms
15,412 KB
testcase_10 AC 361 ms
15,552 KB
testcase_11 AC 998 ms
15,400 KB
testcase_12 AC 298 ms
15,504 KB
testcase_13 AC 1,140 ms
15,380 KB
testcase_14 AC 1,125 ms
15,492 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#!ruby -rprime
N, K = gets.split.map &:to_i

x = N.prime_division
x_primes_h = x.to_h
x_primes_h.default = 0
max_n = ans = 0

(1..N).each{|i|
  y = i.prime_division
  common_divisor = y.map{|k, v|
    [x_primes_h[k], v].min
  }.sum
  if common_divisor >= K
    y_n = y.inject(1){|r, (_, v)| r * (v + 1) }
    if y_n > max_n
      max_n = y_n
      ans = i
    end
  end
}
p ans
0