結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2020-06-15 03:31:44 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 424 bytes |
コンパイル時間 | 350 ms |
コンパイル使用メモリ | 21,708 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-09 01:15:27 |
合計ジャッジ時間 | 1,443 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
Scanf.scanf "%s" (fun s -> let n = String.length s in let rec loop i x y = if i = n then sqrt (float (x * x + y * y)) else match s.[i] with | 'N' -> loop (i + 1) x (y + 1) | 'S' -> loop (i + 1) x (y - 1) | 'E' -> loop (i + 1) (x + 1) y | 'W' -> loop (i + 1) (x - 1) y | _ -> failwith "??" in loop 0 0 0 |> Printf.printf "%f\n" )