結果

問題 No.278 連続する整数の和(2)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-08 13:59:34
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 252 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 11,260 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-10-11 15:19:49
合計ジャッジ時間 3,450 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,288 KB
testcase_01 AC 81 ms
15,108 KB
testcase_02 AC 172 ms
15,128 KB
testcase_03 AC 81 ms
15,040 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 82 ms
15,064 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 163 ms
15,172 KB
testcase_10 AC 188 ms
15,008 KB
testcase_11 WA -
testcase_12 AC 81 ms
15,136 KB
testcase_13 WA -
testcase_14 AC 132 ms
15,136 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 167 ms
15,256 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
sn = n * (n - 1) / 2
t = Math.sqrt(n).to_i
res = 0
t.times do |x|
    x += 1
    if n % x != 0 || sn % x != 0 then
        next
    end
    res += x
    ax = n / x
    if ax != x && sn % ax == 0 then
        res += ax
    end
end
puts res
0