結果

問題 No.1256 連続整数列
ユーザー eseharaesehara
提出日時 2021-06-02 16:38:12
言語 OCaml
(5.1.0)
結果
WA  
実行時間 -
コード長 478 bytes
コンパイル時間 1,356 ms
コンパイル使用メモリ 19,824 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 09:17:19
合計ジャッジ時間 1,073 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1 ms
6,944 KB
testcase_04 WA -
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,940 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,940 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

let is_prime n =
  if n < 2 then false
  else if n = 2 then true
  else if ((n mod 2) = 0) then false
  else
    let sqrt_n = (int_of_float (sqrt (float_of_int n)) + 1) in
    let rec rec_is_prime p =
      let p2_1 = (p * 2) + 1 in
      if (p2_1 > sqrt_n) then true
      else if ((n mod p2_1) = 0) then false
      else rec_is_prime (p + 1) in
    rec_is_prime 1;;

let () =
  read_int () |> (fun x -> if (is_prime x) then "NO" else "YES") |> print_string;print_newline ();;
0