結果
問題 | No.49 算数の宿題 |
ユーザー | iwamot |
提出日時 | 2016-01-25 22:32:20 |
言語 | Ruby (3.3.0) |
結果 |
AC
|
実行時間 | 89 ms / 5,000 ms |
コード長 | 324 bytes |
コンパイル時間 | 53 ms |
コンパイル使用メモリ | 11,288 KB |
実行使用メモリ | 15,300 KB |
最終ジャッジ日時 | 2023-08-24 17:28:48 |
合計ジャッジ時間 | 1,659 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 88 ms
15,288 KB |
testcase_01 | AC | 84 ms
15,104 KB |
testcase_02 | AC | 81 ms
15,248 KB |
testcase_03 | AC | 83 ms
15,104 KB |
testcase_04 | AC | 80 ms
15,244 KB |
testcase_05 | AC | 89 ms
15,284 KB |
testcase_06 | AC | 83 ms
15,140 KB |
testcase_07 | AC | 82 ms
15,132 KB |
testcase_08 | AC | 83 ms
15,112 KB |
testcase_09 | AC | 82 ms
15,300 KB |
コンパイルメッセージ
Syntax OK
ソースコード
s = gets.chomp a = [] n = nil s.chars do |c| case c when '*', '+' a.push n, c n = nil else if n.nil? n = c.to_i else n *= 10 n += c.to_i end end end a.push n ans = a.shift a.each_slice(2) do |o, n| case o when '*' ans += n when '+' ans *= n end end puts ans