結果

問題 No.278 連続する整数の和(2)
ユーザー sugim48sugim48
提出日時 2015-09-04 22:33:33
言語 Ruby
(3.3.0)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 180 bytes
コンパイル時間 740 ms
コンパイル使用メモリ 11,472 KB
実行使用メモリ 15,328 KB
最終ジャッジ日時 2023-08-24 22:34:47
合計ジャッジ時間 4,852 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
15,244 KB
testcase_01 AC 80 ms
15,272 KB
testcase_02 AC 190 ms
15,256 KB
testcase_03 AC 80 ms
15,212 KB
testcase_04 AC 81 ms
15,256 KB
testcase_05 AC 83 ms
15,100 KB
testcase_06 AC 83 ms
15,252 KB
testcase_07 AC 82 ms
15,008 KB
testcase_08 AC 184 ms
15,068 KB
testcase_09 AC 182 ms
15,108 KB
testcase_10 AC 214 ms
15,212 KB
testcase_11 AC 178 ms
15,328 KB
testcase_12 AC 81 ms
15,116 KB
testcase_13 AC 164 ms
15,004 KB
testcase_14 AC 145 ms
15,224 KB
testcase_15 AC 153 ms
15,132 KB
testcase_16 AC 136 ms
15,132 KB
testcase_17 AC 185 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
sum = n * (n + 1) / 2
d = n.gcd(sum)

ans = 0
(1..d).each { |i|
	break if i * i > d
	if d % i == 0
		ans += i
		ans += d / i
	end
	ans -= i if i * i == d
}

puts ans
0