結果
問題 | No.49 算数の宿題 |
ユーザー |
|
提出日時 | 2016-08-18 10:47:26 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 100 ms / 5,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 54 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-12-23 01:53:17 |
合計ジャッジ時間 | 1,682 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
Syntax OK
ソースコード
class Calc0049def initialize(args)args = args.map { |l| l.chomp.split(/\s+/) }@s = args.shift.firstenddef runstack = []@s.scan(/\d+|[+*]/).each do |t|case twhen /\d+/t = t.to_iif stack.empty?stack.push(t)elseop = stack.poptarget = stack.popcase opwhen '+'stack.push(target * t)when '*'stack.push(target + t)endendwhen '+', '*'stack.push(t)endendstack.popendendputs Calc0049.new(STDIN.readlines).run if __FILE__ == $0