結果

問題 No.49 算数の宿題
ユーザー 👑 yumechiyumechi
提出日時 2015-12-01 15:54:06
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 380 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 11,432 KB
実行使用メモリ 15,320 KB
最終ジャッジ日時 2023-08-24 17:27:25
合計ジャッジ時間 1,613 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,100 KB
testcase_01 AC 86 ms
15,320 KB
testcase_02 AC 79 ms
15,300 KB
testcase_03 AC 80 ms
15,296 KB
testcase_04 AC 81 ms
15,244 KB
testcase_05 AC 79 ms
15,152 KB
testcase_06 AC 80 ms
15,148 KB
testcase_07 AC 79 ms
15,152 KB
testcase_08 AC 79 ms
15,136 KB
testcase_09 AC 79 ms
15,292 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

nums = []
marks = []
line = gets.chomp
num = 0
for c in line.split(//) do
    if c == "*" or c == "+"
        marks.push(c)
        nums.push(num)
        num = 0
    else
        num = num * 10 + c.to_i
    end
end
nums.push(num)

res = nums[0]
for i in 0...marks.length do
    if marks[i] == "*"
         res += nums[i+1]
    else
         res *= nums[i+1]
    end
end
puts res
0