結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-01 15:54:06 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 91 ms / 5,000 ms |
| コード長 | 380 bytes |
| コンパイル時間 | 43 ms |
| コンパイル使用メモリ | 7,424 KB |
| 実行使用メモリ | 12,288 KB |
| 最終ジャッジ日時 | 2024-12-23 01:47:01 |
| 合計ジャッジ時間 | 1,457 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
コンパイルメッセージ
Syntax OK
ソースコード
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