結果

問題 No.278 連続する整数の和(2)
ユーザー finefine
提出日時 2016-04-02 23:38:03
言語 Ruby
(3.3.0)
結果
AC  
実行時間 204 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 110 ms
コンパイル使用メモリ 11,236 KB
実行使用メモリ 15,492 KB
最終ジャッジ日時 2023-08-24 22:47:09
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
15,260 KB
testcase_01 AC 90 ms
15,364 KB
testcase_02 AC 204 ms
15,264 KB
testcase_03 AC 91 ms
15,176 KB
testcase_04 AC 91 ms
15,396 KB
testcase_05 AC 89 ms
15,268 KB
testcase_06 AC 91 ms
15,252 KB
testcase_07 AC 91 ms
15,368 KB
testcase_08 AC 90 ms
15,040 KB
testcase_09 AC 90 ms
15,172 KB
testcase_10 AC 90 ms
15,312 KB
testcase_11 AC 103 ms
15,492 KB
testcase_12 AC 90 ms
15,244 KB
testcase_13 AC 165 ms
15,248 KB
testcase_14 AC 100 ms
15,464 KB
testcase_15 AC 133 ms
15,484 KB
testcase_16 AC 101 ms
15,484 KB
testcase_17 AC 99 ms
15,360 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require 'prime'

n = gets.to_i
if n == 1
    p 1
    exit
end
ans = 1
b = Prime.prime_division(n).to_a
if b[0][0] == 2
    b[0][1] -= 1
end
b.each{|a|
    ans *= (a[0] ** (a[1] + 1) - 1) / (a[0] - 1)
    }
p ans
0