結果

問題 No.265 数学のテスト
ユーザー 小指が強い人小指が強い人
提出日時 2015-11-22 21:13:17
言語 Ruby
(3.3.0)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 615 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 11,496 KB
実行使用メモリ 15,520 KB
最終ジャッジ日時 2023-08-16 02:08:28
合計ジャッジ時間 5,219 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
15,520 KB
testcase_01 AC 121 ms
15,356 KB
testcase_02 AC 129 ms
15,384 KB
testcase_03 AC 113 ms
15,468 KB
testcase_04 AC 112 ms
15,372 KB
testcase_05 AC 118 ms
15,312 KB
testcase_06 AC 111 ms
15,520 KB
testcase_07 AC 118 ms
15,292 KB
testcase_08 AC 125 ms
15,360 KB
testcase_09 AC 109 ms
15,376 KB
testcase_10 AC 110 ms
15,508 KB
testcase_11 AC 117 ms
15,400 KB
testcase_12 AC 80 ms
15,056 KB
testcase_13 AC 92 ms
15,264 KB
testcase_14 AC 88 ms
15,436 KB
testcase_15 AC 80 ms
15,260 KB
testcase_16 AC 83 ms
15,104 KB
testcase_17 AC 79 ms
15,096 KB
testcase_18 AC 79 ms
15,052 KB
testcase_19 AC 79 ms
15,276 KB
testcase_20 AC 82 ms
15,140 KB
testcase_21 AC 80 ms
15,056 KB
testcase_22 AC 90 ms
15,140 KB
testcase_23 AC 80 ms
15,252 KB
testcase_24 AC 79 ms
15,372 KB
testcase_25 AC 97 ms
15,352 KB
testcase_26 AC 80 ms
15,128 KB
testcase_27 AC 78 ms
15,052 KB
testcase_28 AC 82 ms
15,428 KB
testcase_29 AC 79 ms
15,252 KB
testcase_30 AC 83 ms
15,420 KB
testcase_31 AC 79 ms
15,168 KB
testcase_32 AC 79 ms
15,088 KB
testcase_33 AC 79 ms
15,052 KB
testcase_34 AC 79 ms
15,172 KB
testcase_35 AC 79 ms
15,136 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n = gets.to_i
d = gets.to_i
s = gets.strip + "+"
n += 1
stack = 0
mstack = 0
const = 1
xnum = 0
a = Array.new(d + 1, 0)
n.times do |i|
    if s[i] == "{"
        stack += 1
    elsif s[i] == "}"
        mstack += 1
    elsif s[i] == "x"
        xnum += 1
    elsif s[i] == "+"
        q = const
        stack.times do |i|
            q *= xnum
            break if xnum == 0
            xnum -= 1
        end
        a[xnum] += q
        stack -= mstack
        mstack = 0
        xnum = 0
        const = 1
    elsif s[i] == "*"
    elsif s[i] == "d"
    else
        const = s[i].to_i
    end
end
puts a.join(" ")
0