結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-06 15:27:12 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
AC
|
| 実行時間 | 44 ms / 5,000 ms |
| コード長 | 767 bytes |
| コンパイル時間 | 44 ms |
| コンパイル使用メモリ | 6,820 KB |
| 実行使用メモリ | 17,920 KB |
| 最終ジャッジ日時 | 2024-12-23 02:04:29 |
| 合計ジャッジ時間 | 1,808 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
(use data.queue)
(let ((s (read-line)))
(print
(let loop ((chars (string->list s))
(stack (make-queue))
(tmp 0))
(cond ((null? chars)
(cond ((queue-empty? stack) (queue-push! stack tmp))
(else
(let1 op (queue-pop! stack)
(queue-push! stack #?=((if (eqv? op #\+) * +) (queue-pop! stack) tmp)))))
(queue-pop! stack))
(else
(let1 char (car chars)
(cond ((char-numeric? char)
(loop (cdr chars) stack (+ (* 10 tmp) (digit->integer char))))
(else
(cond ((queue-empty? stack) (queue-push! stack tmp))
(else
(let1 op (queue-pop! stack)
(queue-push! stack #?=((if (eqv? op #\+) * +) (queue-pop! stack) tmp)))))
(queue-push! stack char)
(loop (cdr chars) stack 0)))))))))