結果

問題 No.667 Mice's Luck(ネズミ達の運)
ユーザー ichibanshiboriichibanshibori
提出日時 2018-09-17 19:14:17
言語 OCaml
(5.1.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 684 bytes
コンパイル時間 58 ms
コンパイル使用メモリ 15,996 KB
最終ジャッジ日時 2023-07-30 07:14:08
合計ジャッジ時間 559 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
File "Main.ml", line 1, characters 5-8:
1 | open Num
         ^^^
Error: Unbound module Num

ソースコード

diff #

open Num

let solve s_arr =
  let n1 = num_of_int 1
  and n100 = num_of_int 100 in

  let rec solve' idx rest_len rest_maru =
    if (idx < len_s_arr) then (
      Printf.printf "%.7f\n" @@ float_of_num @@ rest_maru // rest_len */ n100;
      let rest_maru' = if s_arr.(idx) = 1 then rest_maru -/ n1 else rest_maru in
      solve' (idx + 1) (rest_len -/ n1) rest_maru'
    )
  and len_s_arr = Array.length s_arr
  and cnt_maru =  Array.fold_left ( + ) 0 s_arr |> num_of_int in
  solve' 0 (num_of_int len_s_arr) cnt_maru

let () =
  let s = read_line () in
  let len_s = String.length s in
  let s_arr = Array.init len_s (fun i -> match s.[i] with | 'o' -> 1 | _ -> 0) in
  solve s_arr
0