結果

問題 No.104 国道
ユーザー maimai8
提出日時 2020-08-03 15:45:37
言語 OCaml
(5.2.1)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 315 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 21,700 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-09 01:54:30
合計ジャッジ時間 1,144 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

let () =
  let rec charlist_of_string str n i =
    if i = n then [] else str.[i] :: charlist_of_string str n (i+1) in
  Scanf.scanf "%s\n" @@ fun s ->
  let lst = charlist_of_string s (String.length s) 0 in
  let ans =  List.fold_left (fun a x -> if x = 'L' then a*2 else a*2+1) 1 lst in
  Printf.printf "%d\n" ans
0