結果

問題 No.49 算数の宿題
ユーザー simansiman
提出日時 2016-03-23 14:05:27
言語 Ruby
(3.3.0)
結果
AC  
実行時間 83 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 15,332 KB
最終ジャッジ日時 2023-08-24 17:30:39
合計ジャッジ時間 1,523 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
15,056 KB
testcase_01 AC 83 ms
15,160 KB
testcase_02 AC 77 ms
15,296 KB
testcase_03 AC 82 ms
15,332 KB
testcase_04 AC 77 ms
15,248 KB
testcase_05 AC 76 ms
15,308 KB
testcase_06 AC 77 ms
15,304 KB
testcase_07 AC 76 ms
15,232 KB
testcase_08 AC 80 ms
15,324 KB
testcase_09 AC 77 ms
15,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    s = gets.chomp

    list = s.split(/(\+|\*)/)
    queue = []
    eval_flag = false
    answer = 0

    while !list.empty?
      ch = list.shift

      if ch == '+'
        queue << '*'
        eval_flag = true
      elsif ch == '*'
        queue << '+'
        eval_flag = true
      elsif eval_flag
        queue << ch

        answer = eval(queue.join)

        queue = [answer]
      else 
        queue << ch
      end
    end

    puts answer
  end
end

Yukicoder.new
0