結果
問題 |
No.49 算数の宿題
|
ユーザー |
|
提出日時 | 2017-02-13 20:08:47 |
言語 | Ruby (3.4.1) |
結果 |
AC
|
実行時間 | 91 ms / 5,000 ms |
コード長 | 378 bytes |
コンパイル時間 | 44 ms |
コンパイル使用メモリ | 7,296 KB |
実行使用メモリ | 12,160 KB |
最終ジャッジ日時 | 2024-12-23 01:54:59 |
合計ジャッジ時間 | 1,628 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 10 |
コンパイルメッセージ
Syntax OK
ソースコード
class Solve def initialize str = gets.chomp @list = str.scan(/\d+|[+*]/) end def run result = 0 result = @list[0].to_i len = @list.size - 1 1.step(len, 2) do |i| case @list[i] when '*' result += @list[i+1].to_i when '+' result *= @list[i+1].to_i end end return result end end puts Solve.new.run