結果

問題 No.49 算数の宿題
ユーザー simansiman
提出日時 2016-03-23 14:02:57
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-06-02 07:14:02
合計ジャッジ時間 1,667 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
12,160 KB
testcase_01 AC 79 ms
12,288 KB
testcase_02 AC 78 ms
12,160 KB
testcase_03 AC 80 ms
12,288 KB
testcase_04 AC 83 ms
12,288 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 80 ms
12,288 KB
testcase_09 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class Yukicoder
  def initialize
    s = gets.chomp

    list = s.chars
    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