結果
問題 |
No.1135 RPN
|
ユーザー |
|
提出日時 | 2020-08-15 12:59:42 |
言語 | OCaml (5.2.1) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 651 bytes |
コンパイル時間 | 322 ms |
コンパイル使用メモリ | 21,704 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-09 01:58:52 |
合計ジャッジ時間 | 1,202 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 16 |
ソースコード
Scanf.scanf "%d" (fun n -> let rec loop i stack = if i = n then List.hd stack else let stack = match Scanf.scanf " %s" (fun s -> s) with | "+" -> ( match stack with | x :: y :: tl -> (x + y) :: tl | _ -> stack ) | "-" -> ( match stack with | x :: y :: tl -> (y - x) :: tl | _ -> stack ) | a -> int_of_string a :: stack in loop (i + 1) stack in loop 0 [] |> Printf.printf "%d\n" )