結果

問題 No.278 連続する整数の和(2)
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-08 14:26:22
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 198 ms / 2,000 ms
コード長 273 bytes
コンパイル時間 84 ms
使用メモリ 13,980 KB
最終ジャッジ日時 2023-01-12 15:59:12
合計ジャッジ時間 3,643 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 73 ms
13,800 KB
testcase_01 AC 75 ms
13,852 KB
testcase_02 AC 170 ms
13,720 KB
testcase_03 AC 75 ms
13,804 KB
testcase_04 AC 73 ms
13,804 KB
testcase_05 AC 76 ms
13,836 KB
testcase_06 AC 77 ms
13,724 KB
testcase_07 AC 78 ms
13,980 KB
testcase_08 AC 198 ms
13,832 KB
testcase_09 AC 163 ms
13,840 KB
testcase_10 AC 190 ms
13,940 KB
testcase_11 AC 197 ms
13,836 KB
testcase_12 AC 75 ms
13,824 KB
testcase_13 AC 177 ms
13,864 KB
testcase_14 AC 132 ms
13,848 KB
testcase_15 AC 166 ms
13,800 KB
testcase_16 AC 143 ms
13,804 KB
testcase_17 AC 170 ms
13,800 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 then
        next
    end
    if sn % x == 0 then
        res += x
    end
    ax = n / x
    if ax != x && sn % ax == 0 then
        res += ax
    end
end
puts res
0