結果
| 問題 |
No.49 算数の宿題
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-01 15:50:15 |
| 言語 | Ruby (3.4.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 401 bytes |
| コンパイル時間 | 343 ms |
| コンパイル使用メモリ | 7,296 KB |
| 実行使用メモリ | 12,160 KB |
| 最終ジャッジ日時 | 2024-12-23 01:46:51 |
| 合計ジャッジ時間 | 2,256 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 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