結果

問題 No.278 連続する整数の和(2)
ユーザー finefine
提出日時 2016-04-02 23:38:03
言語 Ruby
(3.1.1p18 )
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 211 bytes
コンパイル時間 32 ms
使用メモリ 14,572 KB
最終ジャッジ日時 2023-01-12 16:01:30
合計ジャッジ時間 3,138 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 88 ms
14,164 KB
testcase_01 AC 87 ms
14,276 KB
testcase_02 AC 188 ms
14,472 KB
testcase_03 AC 87 ms
14,248 KB
testcase_04 AC 87 ms
14,160 KB
testcase_05 AC 87 ms
14,180 KB
testcase_06 AC 87 ms
14,124 KB
testcase_07 AC 87 ms
14,196 KB
testcase_08 AC 87 ms
14,360 KB
testcase_09 AC 87 ms
14,208 KB
testcase_10 AC 89 ms
14,312 KB
testcase_11 AC 99 ms
14,484 KB
testcase_12 AC 88 ms
14,024 KB
testcase_13 AC 156 ms
14,572 KB
testcase_14 AC 94 ms
14,436 KB
testcase_15 AC 127 ms
14,436 KB
testcase_16 AC 97 ms
14,500 KB
testcase_17 AC 95 ms
14,432 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