結果

問題 No.843 Triple Primes
ユーザー pekempeypekempey
提出日時 2019-06-28 21:41:49
言語 OCaml
(5.1.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 271 ms
コンパイル使用メモリ 20,720 KB
実行使用メモリ 11,264 KB
最終ジャッジ日時 2024-04-17 08:48:20
合計ジャッジ時間 2,198 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
11,116 KB
testcase_01 AC 15 ms
11,136 KB
testcase_02 AC 13 ms
11,136 KB
testcase_03 AC 13 ms
11,264 KB
testcase_04 AC 12 ms
11,212 KB
testcase_05 AC 12 ms
11,264 KB
testcase_06 AC 12 ms
11,208 KB
testcase_07 AC 13 ms
11,136 KB
testcase_08 AC 12 ms
11,264 KB
testcase_09 AC 14 ms
11,116 KB
testcase_10 AC 13 ms
11,136 KB
testcase_11 AC 13 ms
11,136 KB
testcase_12 AC 14 ms
11,136 KB
testcase_13 AC 13 ms
11,136 KB
testcase_14 AC 13 ms
11,136 KB
testcase_15 AC 13 ms
11,212 KB
testcase_16 AC 13 ms
11,136 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 13 ms
11,264 KB
testcase_19 AC 13 ms
11,264 KB
testcase_20 AC 13 ms
11,136 KB
testcase_21 AC 12 ms
11,120 KB
testcase_22 AC 13 ms
11,136 KB
testcase_23 AC 13 ms
11,116 KB
testcase_24 AC 13 ms
11,136 KB
testcase_25 AC 14 ms
11,120 KB
testcase_26 AC 14 ms
11,136 KB
testcase_27 AC 13 ms
11,076 KB
testcase_28 AC 13 ms
11,136 KB
testcase_29 AC 11 ms
11,180 KB
testcase_30 AC 14 ms
11,120 KB
testcase_31 AC 12 ms
11,136 KB
testcase_32 AC 13 ms
11,136 KB
testcase_33 AC 13 ms
11,136 KB
testcase_34 AC 13 ms
11,136 KB
testcase_35 AC 14 ms
11,136 KB
testcase_36 AC 15 ms
11,136 KB
testcase_37 AC 15 ms
11,084 KB
testcase_38 AC 14 ms
11,176 KB
testcase_39 AC 14 ms
11,244 KB
testcase_40 AC 14 ms
11,136 KB
testcase_41 AC 2 ms
5,376 KB
testcase_42 AC 15 ms
11,136 KB
testcase_43 AC 13 ms
11,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let n = read_int ();;

if n = 1 then (
  print_endline "0";
  exit 0;
);;

let table = Array.make 500001 true;;
let sqtable = Array.make 500020 false;;

for i = 2 to 500000 do
  if table.(i) then (
    if i <= n && i * i <= 500020 then sqtable.(i*i) <- true;
    for j = 2 to 500000/i do
      table.(i*j) <- false
    done
  )
done;;

let ans = ref 1;;
for i = 3 to n do
  if table.(i) && sqtable.(i+2) then (
    ans := !ans + 2;
  );
done;;

Printf.printf "%d\n" !ans;;
0