結果

問題 No.713 素数の和
ユーザー OrutobaOrutoba
提出日時 2018-08-15 01:24:16
言語 Ruby
(3.3.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 226 bytes
コンパイル時間 481 ms
コンパイル使用メモリ 11,892 KB
実行使用メモリ 16,080 KB
最終ジャッジ日時 2023-10-24 17:23:25
合計ジャッジ時間 1,786 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
16,080 KB
testcase_01 AC 81 ms
16,080 KB
testcase_02 AC 81 ms
16,080 KB
testcase_03 AC 78 ms
16,080 KB
testcase_04 AC 85 ms
16,080 KB
testcase_05 AC 78 ms
16,080 KB
testcase_06 AC 76 ms
16,080 KB
testcase_07 AC 74 ms
16,080 KB
testcase_08 AC 77 ms
16,080 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def pn(n)
  c = 0
  i = 1
  while c < 3 && i <= n
    c += 1 if n % i == 0
    i += 1
  end
  return n if c == 2
end
def pna(n)
  a = []
  n.times do |i|
    a << i+1 if pn(i+1) != nil
  end
  return a
end
p pna(gets.to_i).sum
0