結果

問題 No.1256 連続整数列
ユーザー esehara
提出日時 2021-06-02 16:36:59
言語 OCaml
(5.2.1)
結果
WA  
実行時間 -
コード長 489 bytes
コンパイル時間 1,702 ms
コンパイル使用メモリ 19,824 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 10:09:58
合計ジャッジ時間 2,704 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 4
権限があれば一括ダウンロードができます

ソースコード

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) || (x < 6) then "NO" else "YES") |> print_string;print_newline ();;
0