結果

問題 No.278 連続する整数の和(2)
ユーザー simansiman
提出日時 2022-04-02 15:04:26
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 420 bytes
コンパイル時間 103 ms
使用メモリ 14,636 KB
最終ジャッジ日時 2022-12-27 04:05:05
合計ジャッジ時間 3,189 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 87 ms
14,116 KB
testcase_01 AC 87 ms
14,156 KB
testcase_02 AC 189 ms
14,496 KB
testcase_03 AC 88 ms
14,104 KB
testcase_04 AC 89 ms
14,120 KB
testcase_05 AC 88 ms
14,288 KB
testcase_06 AC 88 ms
14,116 KB
testcase_07 AC 88 ms
14,304 KB
testcase_08 AC 88 ms
14,236 KB
testcase_09 AC 88 ms
14,256 KB
testcase_10 AC 88 ms
14,084 KB
testcase_11 AC 103 ms
14,444 KB
testcase_12 AC 88 ms
14,152 KB
testcase_13 AC 156 ms
14,580 KB
testcase_14 AC 96 ms
14,628 KB
testcase_15 AC 126 ms
14,636 KB
testcase_16 AC 97 ms
14,480 KB
testcase_17 AC 94 ms
14,368 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
a = (N - 1) * N / 2
ans = 0

N.divisor_list.each do |e|
  ans += e if a % e == 0
end

puts ans
0