結果

問題 No.265 数学のテスト
ユーザー char134217728char134217728
提出日時 2017-09-08 07:13:40
言語 Ruby
(3.3.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 760 bytes
コンパイル時間 62 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 19,708 KB
最終ジャッジ日時 2023-08-16 02:11:33
合計ジャッジ時間 7,120 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
外部呼び出し有り
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 195 ms
19,708 KB
testcase_01 AC 174 ms
18,036 KB
testcase_02 AC 168 ms
15,532 KB
testcase_03 AC 167 ms
15,404 KB
testcase_04 AC 163 ms
15,484 KB
testcase_05 AC 163 ms
15,552 KB
testcase_06 AC 161 ms
15,324 KB
testcase_07 AC 170 ms
15,352 KB
testcase_08 AC 176 ms
15,324 KB
testcase_09 AC 167 ms
15,372 KB
testcase_10 AC 164 ms
15,432 KB
testcase_11 AC 165 ms
15,236 KB
testcase_12 AC 149 ms
15,324 KB
testcase_13 AC 159 ms
15,300 KB
testcase_14 AC 153 ms
15,336 KB
testcase_15 AC 144 ms
15,228 KB
testcase_16 AC 149 ms
15,324 KB
testcase_17 AC 147 ms
15,116 KB
testcase_18 AC 145 ms
15,400 KB
testcase_19 AC 151 ms
15,164 KB
testcase_20 AC 154 ms
15,392 KB
testcase_21 AC 146 ms
15,348 KB
testcase_22 AC 153 ms
15,432 KB
testcase_23 AC 147 ms
15,312 KB
testcase_24 AC 150 ms
15,236 KB
testcase_25 AC 167 ms
15,388 KB
testcase_26 AC 147 ms
15,244 KB
testcase_27 AC 155 ms
15,176 KB
testcase_28 AC 160 ms
15,324 KB
testcase_29 AC 151 ms
15,232 KB
testcase_30 AC 154 ms
15,392 KB
testcase_31 AC 148 ms
15,440 KB
testcase_32 AC 146 ms
15,204 KB
testcase_33 AC 143 ms
15,280 KB
testcase_34 AC 144 ms
15,236 KB
testcase_35 AC 145 ms
15,232 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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