結果

問題 No.376 立方体のN等分 (2)
ユーザー simansiman
提出日時 2023-03-28 21:19:55
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 587 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 11,848 KB
実行使用メモリ 21,356 KB
最終ジャッジ日時 2023-10-20 14:26:37
合計ジャッジ時間 13,829 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
16,224 KB
testcase_01 AC 90 ms
16,224 KB
testcase_02 AC 94 ms
16,400 KB
testcase_03 AC 149 ms
16,464 KB
testcase_04 AC 97 ms
16,464 KB
testcase_05 AC 90 ms
16,224 KB
testcase_06 AC 93 ms
16,224 KB
testcase_07 AC 93 ms
16,224 KB
testcase_08 AC 123 ms
16,464 KB
testcase_09 AC 92 ms
16,224 KB
testcase_10 AC 3,444 ms
16,516 KB
testcase_11 AC 142 ms
16,464 KB
testcase_12 AC 100 ms
16,464 KB
testcase_13 AC 96 ms
16,224 KB
testcase_14 AC 100 ms
16,400 KB
testcase_15 AC 171 ms
16,464 KB
testcase_16 TLE -
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 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Integer
  def divisor_list
    require 'prime'

    return [] if self <= 0
    return [1] if self == 1

    prime_division.map.with_index { |(base, k), i|
      s = i.zero? ? 0 : 1 
      (s..k).map { |n| base ** n } 
    }.inject { |res, e| res + res.flat_map { |t| e.map { |v| t * v } } }.sort
  end 
end

N = gets.to_i

min_t = Float::INFINITY
max_t = N - 1
divisor_list = N.divisor_list

divisor_list.each do |a|
  divisor_list.each do |b|
    c, m = N.divmod(a * b)
    next if m != 0

    t = a + b + c - 3
    min_t = t if min_t > t
  end
end

puts [min_t, max_t].join(' ')
0