結果

問題 No.1070 Missing a space
コンテスト
ユーザー esehara
提出日時 2021-06-01 23:21:44
言語 OCaml
(5.5.0)
コンパイル:
ocamlfind ocamlopt -linkpkg -package zarith,str _filename_ -o a.out
実行:
./a.out
結果
AC  
実行時間 1 ms / 1,000 ms
+ 241µs
コード長 525 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 133 ms
コンパイル使用メモリ 21,760 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-21 15:09:52
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
ocamlfind: [WARNING] Cannot read directory ./stublibs which is mentioned in ld.conf

ソースコード

diff #
raw source code

let string_1_list_of_string x =
  String.to_seq x
  |> List.of_seq
  |> List.map (String.make 1);;

let rec solve result one two =
  let h1 = List.hd one in
  let h2 = List.hd two in
  let result = if (h1 <> "0") && (h2 <> "0") then result + 1 else result in
  match (List.length two) with
  | 1 -> result
  | _ -> solve result (one @ [h2]) (List.tl two);;

let () =
  let raw = read_line () |> string_1_list_of_string in
  let hd = [List.hd raw] in
  let tl = List.tl raw in
  solve 0 hd tl |> print_int; print_newline ();;
0