結果

問題 No.843 Triple Primes
ユーザー letrangerjpletrangerjp
提出日時 2019-06-28 22:02:03
言語 Ruby
(3.2.2)
結果
AC  
実行時間 243 ms / 2,000 ms
コード長 208 bytes
コンパイル時間 472 ms
コンパイル使用メモリ 11,888 KB
実行使用メモリ 19,180 KB
最終ジャッジ日時 2023-10-19 17:43:22
合計ジャッジ時間 10,585 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
16,216 KB
testcase_01 AC 238 ms
19,112 KB
testcase_02 AC 105 ms
16,216 KB
testcase_03 AC 104 ms
16,216 KB
testcase_04 AC 108 ms
16,396 KB
testcase_05 AC 101 ms
16,216 KB
testcase_06 AC 109 ms
16,396 KB
testcase_07 AC 238 ms
19,180 KB
testcase_08 AC 240 ms
19,180 KB
testcase_09 AC 234 ms
19,180 KB
testcase_10 AC 239 ms
19,180 KB
testcase_11 AC 243 ms
19,180 KB
testcase_12 AC 238 ms
19,180 KB
testcase_13 AC 236 ms
19,180 KB
testcase_14 AC 238 ms
19,180 KB
testcase_15 AC 233 ms
19,180 KB
testcase_16 AC 237 ms
19,180 KB
testcase_17 AC 100 ms
16,216 KB
testcase_18 AC 99 ms
16,216 KB
testcase_19 AC 99 ms
16,216 KB
testcase_20 AC 134 ms
17,236 KB
testcase_21 AC 118 ms
16,772 KB
testcase_22 AC 170 ms
17,864 KB
testcase_23 AC 169 ms
17,864 KB
testcase_24 AC 137 ms
17,236 KB
testcase_25 AC 134 ms
17,236 KB
testcase_26 AC 237 ms
19,180 KB
testcase_27 AC 109 ms
16,512 KB
testcase_28 AC 235 ms
19,180 KB
testcase_29 AC 135 ms
17,236 KB
testcase_30 AC 236 ms
19,180 KB
testcase_31 AC 109 ms
16,512 KB
testcase_32 AC 105 ms
16,396 KB
testcase_33 AC 136 ms
17,236 KB
testcase_34 AC 169 ms
17,864 KB
testcase_35 AC 236 ms
19,180 KB
testcase_36 AC 118 ms
16,772 KB
testcase_37 AC 173 ms
17,864 KB
testcase_38 AC 170 ms
17,864 KB
testcase_39 AC 236 ms
19,180 KB
testcase_40 AC 100 ms
16,216 KB
testcase_41 AC 99 ms
16,220 KB
testcase_42 AC 231 ms
19,180 KB
testcase_43 AC 235 ms
19,180 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"
N = gets.to_i

rs = Prime.take_while{|r|
  r <= N
}

cnt = 0
rs.each{|r|
  r2 = r * r
  i = 2
  j = r2 - i
  if i <= N && j <= N && i.prime? && j.prime?
    cnt += i == j ? 1 : 2
  end
}
p cnt
0