結果

問題 No.227 簡単ポーカー
ユーザー r6ever6eve
提出日時 2017-08-11 14:07:36
言語 OCaml
(5.1.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 719 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 21,632 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-17 08:39:50
合計ジャッジ時間 819 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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