結果
問題 |
No.49 算数の宿題
|
ユーザー |
|
提出日時 | 2015-12-01 15:53:27 |
言語 | Ruby (3.4.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 395 bytes |
コンパイル時間 | 45 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,288 KB |
最終ジャッジ日時 | 2024-12-23 01:46:55 |
合計ジャッジ時間 | 1,559 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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) p nums p marks 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