結果

問題 No.227 簡単ポーカー
コンテスト
ユーザー r6eve
提出日時 2017-08-11 14:07:36
言語 OCaml
(5.4.1)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 719 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 74 ms
コンパイル使用メモリ 19,712 KB
最終ジャッジ日時 2026-04-25 04:29:12
合計ジャッジ時間 866 ms
ジャッジサーバーID
(参考情報)
judge3_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
File "Main.ml", line 9, characters 43-44:
9 |       else if compare (unsafe_get a i) x = 0 then true
                                               ^
Error: The constant 0 has type int but an expression was expected of type
         'a array -> int

ソースコード

diff #
raw source code

module Array = struct
  include Array

  (* @since 4.03.0 *)
  let mem x a =
    let n = length a in
    let rec loop i =
      if i = n then false
      else if compare (unsafe_get a i) x = 0 then true
      else loop (succ i) in
    loop 0

end

let n = 5

let () =
  let a = Array.make 13 0 in
  for i = 0 to n - 1 do
    let x = Scanf.scanf "%d " (fun i -> i) in
    let x = x - 1 in
    a.(x) <- a.(x) + 1;
  done;
  let s = Array.mem 3 a in
  let t = Array.mem 2 a in
  let r =
    if s && t then "FULL HOUSE"
    else if s then "THREE CARD"
    else if not t then "NO HAND"
    else if Array.fold_left (fun m e ->
      m + if e = 2 then 1 else 0) 0 a = 2 then "TWO PAIR"
    else "ONE PAIR" in
  print_endline r
0