結果

問題 No.278 連続する整数の和(2)
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-08-09 05:15:11
言語 Ruby
(3.3.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 225 bytes
コンパイル時間 57 ms
コンパイル使用メモリ 11,552 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-08-24 22:48:00
合計ジャッジ時間 3,341 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,220 KB
testcase_01 AC 83 ms
15,116 KB
testcase_02 AC 165 ms
15,020 KB
testcase_03 AC 79 ms
15,108 KB
testcase_04 AC 79 ms
15,072 KB
testcase_05 AC 82 ms
15,192 KB
testcase_06 AC 83 ms
15,268 KB
testcase_07 AC 84 ms
15,144 KB
testcase_08 AC 192 ms
15,284 KB
testcase_09 AC 156 ms
15,152 KB
testcase_10 AC 178 ms
15,144 KB
testcase_11 AC 185 ms
15,288 KB
testcase_12 AC 80 ms
15,328 KB
testcase_13 AC 168 ms
15,272 KB
testcase_14 AC 130 ms
15,276 KB
testcase_15 AC 156 ms
15,044 KB
testcase_16 AC 141 ms
15,284 KB
testcase_17 AC 160 ms
15,112 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i

sum = N * (N - 1) / 2

ans = 0

1.upto(Math.sqrt(N).floor) {|i|
  if N % i == 0
    if sum % i == 0
      ans += i
    end

    if sum % (N / i) == 0 and i != N / i
      ans += N / i
    end
  end
}

puts ans
0