結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
16,248 KB
testcase_01 AC 94 ms
16,248 KB
testcase_02 AC 120 ms
16,492 KB
testcase_03 TLE -
testcase_04 AC 138 ms
16,492 KB
testcase_05 AC 95 ms
16,252 KB
testcase_06 AC 95 ms
16,248 KB
testcase_07 AC 94 ms
16,248 KB
testcase_08 AC 127 ms
16,492 KB
testcase_09 AC 98 ms
16,428 KB
testcase_10 TLE -
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 -- -
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

N.divisor_list.repeated_combination(3).each do |a, b, c|
  next if a * b * c != N

  t = (a - 1) + (b - 1) + (c - 1)
  min_t = t if min_t > t
end

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