結果

問題 No.265 数学のテスト
ユーザー char134217728
提出日時 2017-09-08 07:13:40
言語 Ruby
(3.4.1)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 760 bytes
コンパイル時間 308 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-11-24 11:35:03
合計ジャッジ時間 4,662 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

if !ENV['RUBY_THREAD_VM_STACK_SIZE']
  exec({'RUBY_THREAD_VM_STACK_SIZE'=>'1000000000'}, '/usr/bin/ruby', $0)
end
gets
@m = gets.to_i
@s = gets.chomp
@i = 0
@s << ?}
def calc
  ret = [0]*(@m+1)
  t = [0, 0]
  while true do
    case @s[@i]
    when /\d/
      t = [0, @s[@i].to_i]
      @i += 1
    when ?*
      @i += 1
      case @s[@i]
      when /\d/
        t[1] *= @s[@i].to_i
      else
        t[0] += 1
      end
      @i += 1
    when ?x
      t = [1, 1]
      @i += 1
    when ?+
      ret[t[0]] += t[1]
      t = [0, 0]
      @i += 1
    when ?d
      @i += 2
      _t = calc
      (1..@m).each do |j|
        ret[j-1] += j * _t[j]
      end
    when ?}
      ret[t[0]] += t[1]
      @i += 1
      return ret
    else
    end
  end
end
puts calc*' '
0